diff options
author | bugwz <cubegwz@gmail.com> | 2022-08-29 12:40:14 -0700 |
---|---|---|
committer | Michael Grunder <michael.grunder@gmail.com> | 2022-08-31 09:42:10 -0700 |
commit | 0a5fa3ddee9059e8ca98f6ac0f5683aba31f5173 (patch) | |
tree | a81179b423332c43392f0191bb44b83b7bc786e2 /test.c | |
parent | 9e174e8f7d134fea69b0afd7e36443009b83badf (diff) |
Regression test for off-by-one parsing error
See: #916
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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(); |