Fix edge case when second hex digit is NUL
This commit is contained in:
parent
ee311f5ca7
commit
05bbadf3a5
1 changed files with 2 additions and 2 deletions
|
@ -92,11 +92,11 @@ void process_escapes(std::string& input) {
|
||||||
case '\\': input[output_idx++] = '\\'; break;
|
case '\\': input[output_idx++] = '\\'; break;
|
||||||
case 'x':
|
case 'x':
|
||||||
// Handle \x12, etc
|
// Handle \x12, etc
|
||||||
if (input_idx + 2 < input_len && input[input_idx + 1] != 0) {
|
if (input_idx + 2 < input_len) {
|
||||||
const char x[3] = { input[input_idx + 1], input[input_idx + 2], 0 };
|
const char x[3] = { input[input_idx + 1], input[input_idx + 2], 0 };
|
||||||
char *err_p = nullptr;
|
char *err_p = nullptr;
|
||||||
const long val = std::strtol(x, &err_p, 16);
|
const long val = std::strtol(x, &err_p, 16);
|
||||||
if (*err_p == 0) {
|
if (err_p == x + 2) {
|
||||||
input_idx += 2;
|
input_idx += 2;
|
||||||
input[output_idx++] = char(val);
|
input[output_idx++] = char(val);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue