From 2b4c03fcdbc666d343ef9e4e5478d39f4654e9e9 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Fri, 2 Feb 2018 13:39:30 +0100 Subject: [PATCH] tests: fix abbreviated octal escape check in print_quoted_memory * tests/print_quoted_string.c (print_quoted_memory): Check the next character after octal-escaped one instead of the first one in the string. --- tests/print_quoted_string.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/print_quoted_string.c b/tests/print_quoted_string.c index 2894e49b..4107e256 100644 --- a/tests/print_quoted_string.c +++ b/tests/print_quoted_string.c @@ -68,7 +68,9 @@ print_quoted_memory(const void *const instr, const size_t len) char c2 = '0' + ((c >> 3) & 0x7); char c3 = '0' + (c >> 6); - if (*str >= '0' && *str <= '9') { + if (i < (len - 1) && + str[i + 1] >= '0' && + str[i + 1] <= '9') { /* Print \octal */ putchar(c3); putchar(c2); -- 2.40.0