RWCString::toLower() function call creates runtime error.

Article ID: 803
Last updated: 05 Feb, 2008
Article ID: 803
Last updated: 05 Feb, 2008
Revision: 1
Views: 3373
Posted: 25 Jun, 1997
by Dean J.
Updated: 05 Feb, 2008
by Dean J.
Problem


When building a Tools.h++ library compiled with RWDEBUG defined, the following test case will produce a segmentation fault at run time:
main() {
RWCString s;
s.toLower();
return 0; }
Result: Segmentation fault core dump.


Cause


An optimization in the copy-on-write mechanism that prevents empty strings from being copied causes this error.


Action


This error can be fixed by modifying the assertions in the file cstring.cpp in the method RWCString::clone (both clone() and clone(size_t)).
  RWPOSTCONDITION(pref()->references() == 1);
becomes
  RWPOSTCONDITION(pref()->references() == 1 || temp == nullStringRef);
The same problem appears in the RWWString class. The same fix applies here.
This article was:   Helpful | Not helpful
Report an issue
Article ID: 803
Last updated: 05 Feb, 2008
Revision: 1
Views: 3373
Posted: 25 Jun, 1997 by Dean J.
Updated: 05 Feb, 2008 by Dean J.

Others in this category