[Scummvm-cvs-logs] SF.net SVN: scummvm:[50712] scummvm/trunk/common
wjpalenstijn at users.sourceforge.net
wjpalenstijn at users.sourceforge.net
Mon Jul 5 23:29:52 CEST 2010
Revision: 50712
http://scummvm.svn.sourceforge.net/scummvm/?rev=50712&view=rev
Author: wjpalenstijn
Date: 2010-07-05 21:29:52 +0000 (Mon, 05 Jul 2010)
Log Message:
-----------
Note Common::String's behaviour may be undefined with \0 characters.
Also make operator=(char) and String(char) behave the same.
Modified Paths:
--------------
scummvm/trunk/common/str.cpp
scummvm/trunk/common/str.h
Modified: scummvm/trunk/common/str.cpp
===================================================================
--- scummvm/trunk/common/str.cpp 2010-07-05 21:29:15 UTC (rev 50711)
+++ scummvm/trunk/common/str.cpp 2010-07-05 21:29:52 UTC (rev 50712)
@@ -105,8 +105,6 @@
_storage[0] = c;
_storage[1] = 0;
- // TODO/FIXME: There is no reason for the following check -- we *do*
- // allow strings to contain 0 bytes!
_size = (c == 0) ? 0 : 1;
}
@@ -256,9 +254,11 @@
String &String::operator=(char c) {
decRefCount(_extern._refCount);
_str = _storage;
- _size = 1;
+
_str[0] = c;
_str[1] = 0;
+
+ _size = (c == 0) ? 0 : 1;
return *this;
}
Modified: scummvm/trunk/common/str.h
===================================================================
--- scummvm/trunk/common/str.h 2010-07-05 21:29:15 UTC (rev 50711)
+++ scummvm/trunk/common/str.h 2010-07-05 21:29:52 UTC (rev 50712)
@@ -39,6 +39,9 @@
* Instead, small strings are stored 'inside' the string object (i.e. on
* the stack, for stack allocated objects), and only for strings exceeding
* a certain length do we allocate a buffer on the heap.
+ *
+ * The presence of \0 characters in the string will cause undefined
+ * behaviour in some operations.
*/
class String {
protected:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list