From 0a5fa3ddee9059e8ca98f6ac0f5683aba31f5173 Mon Sep 17 00:00:00 2001 From: bugwz Date: Mon, 29 Aug 2022 12:40:14 -0700 Subject: Regression test for off-by-one parsing error See: #916 --- test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test.c b/test.c index 2447545..7d3e70a 100644 --- a/test.c +++ b/test.c @@ -578,6 +578,19 @@ static void test_reply_reader(void) { test_cond(ret == REDIS_ERR && reply == NULL); redisReaderFree(reader); + test("Don't reset state after protocol error(not segfault): "); + reader = redisReaderCreate(); + redisReaderFeed(reader,(char*)"*3\r\n$3\r\nSET\r\n$5\r\nhello\r\n$", 25); + ret = redisReaderGetReply(reader,&reply); + assert(ret == REDIS_OK); + redisReaderFeed(reader,(char*)"3\r\nval\r\n", 8); + ret = redisReaderGetReply(reader,&reply); + test_cond(ret == REDIS_OK && + ((redisReply*)reply)->type == REDIS_REPLY_ARRAY && + ((redisReply*)reply)->elements == 3); + freeReplyObject(reply); + redisReaderFree(reader); + /* Regression test for issue #45 on GitHub. */ test("Don't do empty allocation for empty multi bulk: "); reader = redisReaderCreate(); -- cgit v1.2.3