From ebc3a6b0387af83c6735f89dbde98ca425741b3b Mon Sep 17 00:00:00 2001 From: Antonio Cervone Date: Wed, 2 Dec 2015 10:01:29 +0100 Subject: [PATCH] watch out for i+1 to overflow the buffer --- json11.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/json11.cpp b/json11.cpp index 3ec83af..ebd7e93 100644 --- a/json11.cpp +++ b/json11.cpp @@ -389,12 +389,12 @@ struct JsonParser { } else if (str[i] == '*') { // multiline comment i++; - if (i == str.size()) + if (i > str.size()-2) return fail("unexpected end of input inside multi-line comment", 0); - // advance until closing tokens + // advance until closing tokens while (!(str[i] == '*' && str[i+1] == '/')) { i++; - if (i == str.size()) + if (i > str.size()-2) return fail( "unexpected end of input inside multi-line comment", 0); }