Boost logo

Boost Users :

From: Mick Hollins (mick_at_[hidden])
Date: 2005-12-01 05:25:56


Caleb Epstein wrote:

> On 11/28/05, *Mick Hollins* <mick_at_[hidden]
> <mailto:mick_at_[hidden]>> wrote:
>
> The following code causes a runtime assertion in VC 8.0:
>
> std::string l_param;
> std::string l_str = (boost::format("here is an empty string:
> %1%") % l_param).str();
>
> It passes an empty string argument to boost::format.
> The assert is inside the implementation of basic_string::append()
> and boils down to the fact that the implementation of
> boost::format ends up calling
> basic_string::append(const char *, size_type) with a null pointer,
> which causes
> basic_string::append to assert.
>
>
>
> This assertion seems to only happen with /MDd (e.g. debug runtime),
> but I'd say it qualifies as a bug in Boost.Format.

yes I agree.

>
>
> And here's the offending code from boost::io::detail::mk_str
> (feed_args.hpp):
>
>
> typedef typename std::basic_string<Ch,Tr,Alloc>::size_type
> size_type;
> res.resize(0);
> if(w<=0 || static_cast<size_type>(w) <=size) {
> // no need to pad.
> res.reserve(size + !!prefix_space);
> if(prefix_space)
> res.append(1, prefix_space);
> => res.append(beg, size);
> }
>
> I think the simple and obvious fix is to just check for size != 0
> before calling res.append, but I'm not familiar with this code.

Yep that seems like the obvious fix. I've not yet been involved in
contributing to boost, but am happy to do so, so I'm gonna read up on
exactly how one goes about getting a change into the base and go from
there. I presume there's doco somewhere on the boost site that tells me
how to get started ...

cheers,
mick



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net