diff options
author | Eugene Sandulenko | 2020-01-06 13:31:58 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2020-01-06 13:31:58 +0100 |
commit | a6307b768c1d1771c031cc8061a929b45a3d66ac (patch) | |
tree | c450f55f87ecd1963e7e6b5ebc4b368e9cc573e6 /common | |
parent | 14719c46c718cf284bde7d54842ec338510aa273 (diff) | |
download | scummvm-rg350-a6307b768c1d1771c031cc8061a929b45a3d66ac.tar.gz scummvm-rg350-a6307b768c1d1771c031cc8061a929b45a3d66ac.tar.bz2 scummvm-rg350-a6307b768c1d1771c031cc8061a929b45a3d66ac.zip |
COMMON: Fix reading beyond array pointers in toString()
Diffstat (limited to 'common')
-rw-r--r-- | common/str.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/common/str.cpp b/common/str.cpp index 0082dc1bec..ad9e17806e 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -1097,7 +1097,7 @@ size_t strnlen(const char *src, size_t maxSize) { String toPrintable(const String &in, bool keepNewLines) { Common::String res; - const char *tr = "\x01\x02\x03\x04\x05\x06" "a" + const char *tr = "\x01\x01\x02\x03\x04\x05\x06" "a" //"\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"; "b" "t" "n" "v" "f" "r\x0e\x0f" "\x10\x11\x12\x13\x14\x15\x16\x17" @@ -1117,10 +1117,10 @@ String toPrintable(const String &in, bool keepNewLines) { res += '\\'; if (*p < 0x20) { - if (tr[*p + 1] < 0x20) + if (tr[*p] < 0x20) res += Common::String::format("x%02x", *p); else - res += tr[*p + 1]; + res += tr[*p]; } else { res += *p; // We will escape it } |