From a7ed8fa56423636ca5e455bcd62684a54672da57 Mon Sep 17 00:00:00 2001 From: Philip Guenther Date: Fri, 18 Oct 2013 15:38:55 +0100 Subject: [PATCH] fix off-by one error in a2p The str_gets() function, when encountering a newline character, checked to see if the previous char was a \ escape. For a blank line, the check would read the char at the position one before the start of the buffer. There was a test to avoid this, but it was off-by-one. --- AUTHORS | 1 + x2p/str.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 9fd9eac..b84a6e4 100644 --- a/AUTHORS +++ b/AUTHORS @@ -930,6 +930,7 @@ Petter Reinholdtsen Phil Lobbes Phil Monsen Philip Boulain +Philip Guenther Philip Hazel Philip M. Gollucci Philip Newton diff --git a/x2p/str.c b/x2p/str.c index 86127a0..e12e5e9 100644 --- a/x2p/str.c +++ b/x2p/str.c @@ -200,7 +200,7 @@ str_gets(STR *str, FILE *fp) for (;;) { while (--cnt >= 0) { if ((*bp++ = *ptr++) == newline) { - if (bp <= str->str_ptr || bp[-2] != '\\') + if (bp <= str->str_ptr + 1 || bp[-2] != '\\') goto thats_all_folks; else { line++; -- 2.7.4