From 5e6a2fa256206de367b351de7dfa4b56d4f1a812 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 28 May 2014 00:30:11 +0900 Subject: [PATCH] Assert ctx->state >= 0 in huffman decoding --- lib/nghttp2_hd_huffman.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nghttp2_hd_huffman.c b/lib/nghttp2_hd_huffman.c index 4fe3a07d..c1713ddf 100644 --- a/lib/nghttp2_hd_huffman.c +++ b/lib/nghttp2_hd_huffman.c @@ -177,7 +177,11 @@ ssize_t nghttp2_hd_huff_decode(nghttp2_hd_huff_decode_context *ctx, for(i = 0; i < srclen; ++i) { uint8_t in = src[i] >> 4; for(j = 0; j < 2; ++j) { - const nghttp2_huff_decode *t = &huff_decode_table[ctx->state][in]; + const nghttp2_huff_decode *t; + + assert(ctx->state >= 0); + + t = &huff_decode_table[ctx->state][in]; if(t->state == -1) { return NGHTTP2_ERR_HEADER_COMP; }