From 16e05c582c39e0aa4f0ef6dd70756fded6516d25 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sun, 4 Nov 2018 22:09:28 +0800 Subject: Codegen C - Fix minor OOB string read --- src/trans/codegen_c.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/trans/codegen_c.cpp') 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(v); else m_of << "\\x" << (unsigned int)static_cast(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 << "\"\""; } } -- cgit v1.2.3