From 459507f534c807d8ba741730fbc36d4b93b133c1 Mon Sep 17 00:00:00 2001 From: Cliff Frey Date: Sat, 11 Sep 2010 16:55:56 -0700 Subject: [PATCH] avoid assertion failure in error case Without this change, it is possible to get an assertion to fail by continuing to call http_parser_execute after it has returned an error. Specifically, the parser could be called with parser->state == s_chunk_size_almost_done and parser->flags & F_CHUNKED set. Then, F_CHUNKED could have been cleared, and an error could be hit. In this case, the parser would have returned with F_CHUNKED clear, but parser->state == s_chunk_size_almost_done, resulting in an assertion failure on the next call. There are alternate solutions possible, including just saving all of the fields (state included) on error. I didn't add a test case because this is a bit annoying to test, but I can add one if necesssary. --- http_parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/http_parser.c b/http_parser.c index e94075d8..3f9bfdcc 100644 --- a/http_parser.c +++ b/http_parser.c @@ -1545,6 +1545,7 @@ size_t http_parser_execute (http_parser *parser, return len; error: + parser->state = s_dead; return (p - data); }