]> granicus.if.org Git - strace/blobdiff - tests/print_quoted_string.c
tests: fix abbreviated octal escape check in print_quoted_memory
[strace] / tests / print_quoted_string.c
index 2894e49bc35e8edbecdb62106adc6c01c6d8ac9f..4107e256056364b99b9ed300211df0a8df5b42dc 100644 (file)
@@ -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);