Boost logo

Boost Users :

Subject: Re: [Boost-users] [Filesystem] String corruption in path in V3 and Boost 1.44
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2010-09-22 21:40:50


On Wed, Sep 22, 2010 at 13:42, Timothy Madden <terminatorul_at_[hidden]> wrote:
>
> I think that somehow the template constructor for paths takes the entire
> array passed as argument and not just the null-terminated string inside the
> array, which may be smaller.
>

That's plausible. A number of places in boost like to do that because
it allows for embedded nulls in string literals:

    path p("1234\0abc");

Considering that every filesystem I know of doesn't accept nulls,
though, it really doesn't matter for paths.

You can get the expected behavour from your code with fs::path p((char
const*)b);

I suspect it's just that nobody ever considered people using char
arrays that weren't string literals, since the "boost way" would have
it inside a vector or boost::array, and do fs::path(array.data())
which wouldn't trigger the problem.

HTH,
~ Scott


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