summaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
authorbugwz <cubegwz@gmail.com>2022-08-29 12:40:14 -0700
committerMichael Grunder <michael.grunder@gmail.com>2022-08-31 09:42:10 -0700
commit0a5fa3ddee9059e8ca98f6ac0f5683aba31f5173 (patch)
treea81179b423332c43392f0191bb44b83b7bc786e2 /test.c
parent9e174e8f7d134fea69b0afd7e36443009b83badf (diff)
Regression test for off-by-one parsing error
See: #916
Diffstat (limited to 'test.c')
-rw-r--r--test.c13
1 files changed, 13 insertions, 0 deletions
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();