[Scummvm-devel] zero bytes in Common::String

Willem Jan Palenstijn wjp at usecode.org
Tue Jun 29 12:06:39 CEST 2010


Hi,

There's some confusion in Common::String about whether zero bytes are allowed
in Common::String or not.

The String::String(char c) constructor has an explicit comment saying it's
allowed, but many methods use either c_str() internally or strcmp, strstr, ...,
which might lead to surprising behaviour.

And as fuzzie pointed out on IRC, String &String::operator=(char c) is also
inconsistent with String::String(char c) in this respect.

Any opinions on what we should do?

Unless there's a reason we need zero byte support in strings, the easiest would
be simply saying it's not allowed and leads to undefined behaviour.


-Willem Jan




More information about the Scummvm-devel mailing list