From 2f5c64225d4bbb9c5189d940cce65189c8d3c3ad Mon Sep 17 00:00:00 2001 From: Antonio Cervone Date: Mon, 30 Nov 2015 12:40:20 +0100 Subject: [PATCH] detect malformed comments --- json11.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/json11.cpp b/json11.cpp index a1efd61..f67fda5 100644 --- a/json11.cpp +++ b/json11.cpp @@ -383,11 +383,16 @@ struct JsonParser { else if (str[i] == '*') { // multiline comment i++; // advance until closing tokens - while (!(str[i] == '*' && str[i+1] == '/')) - i++; + while (!(str[i] == '*' && str[i+1] == '/')) { + if (i == str.size()) + return fail( + "unexpected end of input inside multi-line comment", 0); + i++;} i += 2; comment_found = true; } + else + return fail("malformed comment", 0); } return comment_found; }