summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hodge <tpg@ucc.asn.au>2018-11-04 22:09:28 +0800
committerJohn Hodge <tpg@ucc.asn.au>2018-11-04 22:09:28 +0800
commit16e05c582c39e0aa4f0ef6dd70756fded6516d25 (patch)
tree91e8a8fa48edabbfc002810675dd12a5df0230bf
parent1726886913173c2828e962d7c5d384e3915d0ae3 (diff)
downloadmrust-16e05c582c39e0aa4f0ef6dd70756fded6516d25.tar.gz
Codegen C - Fix minor OOB string read
-rw-r--r--src/trans/codegen_c.cpp5
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 << "\"\"";
}
}