Imay have come across a little bug in the implementation of the OFString::copy() in version 3.6.0 (ofstring.cc line 434)
The referred method didn´t work as expected and when I traced it found that the copyMem function was copying the original string and not the desired substring.
[code]
size_t
OFString::copy (char* s, size_t n, size_t pos) const
{
OFString sub(this->substr(pos, n));
// String length *including* the trailing EOS
const size_t result = sub.size() + 1;
// The string could have NULL bytes so no strncpy()
OFBitmanipTemplate<char>::copyMem(this->theCString, s, result);
return result;
}
should be:
size_t
OFString::copy (char* s, size_t n, size_t pos) const
{
OFString sub(this->substr(pos, n));
// String length *including* the trailing EOS
const size_t result = sub.size() + 1;
// The string could have NULL bytes so no strncpy()
OFBitmanipTemplate<char>::copyMem(sub, s, result); // copy the substring to s
return result;
}
[/code]
Possible bug in OFString::copy()
Moderator: Moderator Team
Re: Possible bug in OFString::copy()
sorry, the line shoud have been
OFBitmanipTemplate<char>::copyMem(sub->theCString, s, result); // copy the substring to s
OFBitmanipTemplate<char>::copyMem(sub->theCString, s, result); // copy the substring to s
-
- DCMTK Developer
- Posts: 2506
- Joined: Tue, 2011-05-03, 14:38
- Location: Oldenburg, Germany
- Contact:
Re: Possible bug in OFString::copy()
Thank you for the report. I guess you are right. This pretty much looks like a bug (that has been introduced with adding support for 0 bytes within a character string some time ago). We will fix this and let you know ...
-
- DCMTK Developer
- Posts: 120
- Joined: Thu, 2009-11-26, 08:15
Re: Possible bug in OFString::copy()
Again, thank you for the report. This was now fixed in the latest development version. Also, the return value of copyMem() was wrong and some more unit tests were added. For more information, see:
http://git.dcmtk.org/web?p=dcmtk.git;a= ... 30ba4045fa
http://git.dcmtk.org/web?p=dcmtk.git;a= ... 30ba4045fa
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest