diff options
author | John Hodge <tpg@ucc.asn.au> | 2018-11-04 22:09:28 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2018-11-04 22:09:28 +0800 |
commit | 16e05c582c39e0aa4f0ef6dd70756fded6516d25 (patch) | |
tree | 91e8a8fa48edabbfc002810675dd12a5df0230bf /src/trans/codegen_c.cpp | |
parent | 1726886913173c2828e962d7c5d384e3915d0ae3 (diff) | |
download | mrust-16e05c582c39e0aa4f0ef6dd70756fded6516d25.tar.gz |
Codegen C - Fix minor OOB string read
Diffstat (limited to 'src/trans/codegen_c.cpp')
-rw-r--r-- | src/trans/codegen_c.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/trans/codegen_c.cpp b/src/trans/codegen_c.cpp index b578c09b..55b3ea1a 100644 --- a/src/trans/codegen_c.cpp +++ b/src/trans/codegen_c.cpp @@ -1975,9 +1975,8 @@ namespace { m_of << "\\x0" << (unsigned int)static_cast<uint8_t>(v); else m_of << "\\x" << (unsigned int)static_cast<uint8_t>(v); - // If the next character is a hex digit, - // close/reopen the string. - if( isxdigit(*(&v+1)) ) + // If the next character is a hex digit, close/reopen the string. + if( &v < &s.back() && isxdigit(*(&v+1)) ) m_of << "\"\""; } } |