diff options
author | hjk <[email protected]> | 2013-06-20 12:14:30 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2013-06-20 12:21:47 +0200 |
commit | 209bad4213e1e4a7dd218ef6fb6e9e74a182f623 (patch) | |
tree | ccb2019c96bcd1d4ca3825a961f7928c33e8e1ec /src/plugins/debugger/debuggerprotocol.cpp | |
parent | 24b8ef317db2e4116b8549a1047f7e07b2e0cc5d (diff) |
Debugger: Fix reading of \x escape sequences in strings
Change-Id: Idfe41f6c2769397d6eee3ab74de4afbb94111e25
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/debugger/debuggerprotocol.cpp')
-rw-r--r-- | src/plugins/debugger/debuggerprotocol.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/plugins/debugger/debuggerprotocol.cpp b/src/plugins/debugger/debuggerprotocol.cpp index c5c418a22e2..b837ef80ce4 100644 --- a/src/plugins/debugger/debuggerprotocol.cpp +++ b/src/plugins/debugger/debuggerprotocol.cpp @@ -38,6 +38,17 @@ namespace Debugger { namespace Internal { +uchar fromhex(uchar c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'z') + return 10 + c - 'a'; + if (c >= 'A' && c <= 'Z') + return 10 + c - 'A'; + return -1; +} + void skipCommas(const char *&from, const char *to) { while (*from == ',' && from != to) @@ -120,6 +131,26 @@ QByteArray GdbMi::parseCString(const char *&from, const char *to) case 'v': *dst++ = '\v'; break; case '"': *dst++ = '"'; break; case '\\': *dst++ = '\\'; break; + case 'x': { + c = *src++; + int chars = 0; + uchar prod = 0; + while (true) { + uchar val = fromhex(c); + if (val == uchar(-1)) + break; + prod = prod * 16 + val; + if (++chars == 3 || src == end) + break; + c = *src++; + } + if (!chars) { + qDebug() << "MI Parse Error, unrecognized hex escape"; + return QByteArray(); + } + *dst++ = prod; + break; + } default: { int chars = 0; |