Skip to content

Commit 6d1898e

Browse files
committed
Fix use-after-free bug
C++ strikes again.
1 parent 15d3ca5 commit 6d1898e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/GdbCommandHandler.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ static string gdb_unescape(const string& str) {
210210
}
211211
stringstream ss;
212212
for (size_t i = 0; i < len; i += 2) {
213-
const char *hex_str = str.substr(i, 2).c_str();
213+
string substr = str.substr(i, 2);
214+
const char *hex_str = substr.c_str();
214215
char *ptr = nullptr;
215216
ss << (char)strtoul(hex_str, &ptr, 16);
216217
// check for unexpected character

0 commit comments

Comments
 (0)