aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-05-30 13:10:44 +0000
committerJohannes Schickel2010-05-30 13:10:44 +0000
commitf02e31f2fca7299695e006f0a0bffbebe115d8e9 (patch)
tree297620360f6ecfcb696a993e15f83361e96d25e9
parent0e9156c7c4d481a0f43b232207dd6065779e9765 (diff)
downloadscummvm-rg350-f02e31f2fca7299695e006f0a0bffbebe115d8e9.tar.gz
scummvm-rg350-f02e31f2fca7299695e006f0a0bffbebe115d8e9.tar.bz2
scummvm-rg350-f02e31f2fca7299695e006f0a0bffbebe115d8e9.zip
Fix non-const version of Common::String::begin.
Common::String::begin now assures the storage is a unique one, i.e. there are no other Common::String objects pointing at it. This allows for safe use of the writable iterators (and thus fixes the test case added with my last commit) svn-id: r49323
-rw-r--r--common/str.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/str.h b/common/str.h
index 12e2b0d2d3..74bcb42264 100644
--- a/common/str.h
+++ b/common/str.h
@@ -222,6 +222,12 @@ public:
typedef const char * const_iterator;
iterator begin() {
+ // Since the user could potentionally
+ // change the string via the returned
+ // iterator we have to assure we are
+ // pointing to an unique storage.
+ makeUnique();
+
return _str;
}