Boost logo

Boost Users :

Subject: Re: [Boost-users] [Filesystem] String corruption in path in V3 and Boost 1.44
From: Will Watts (willw_at_[hidden])
Date: 2010-09-22 13:36:56


In article <i7db7c$kid$1_at_[hidden]>, Timothy Madden wrote:
> I do not know about the Filesystem maintainer, but we need a minimal
> example to reproduce the problem to make our case elsewhere, that is on
> the bug tracker or on another list.

How about this?

void main() {
  const char * f = "foo";
  char b[5];
  strcpy(b, f);
  fs::path p1(b); // Debugger shows p1.m_pathname.size = 4 after this
  fs::path p2(f); // But p2.m_pathname.size = 3
  cout << p1 << endl; // prints "foo "
  cout << p2 << endl; // prints "foo"
  cout << (p1 == p2) << endl; // prints 1 - they are supposedly identical
}

Please can you check that I haven't cocked up the strcpy(), or something
idiotic! By all means repeat the exercise with wide characters.

This doesn't show a spectacular crash, but I think it shows that something is
amiss with the C array handling - something to do with the terminating zero
byte? What do you reckon?

Will


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