Skip to content

Commit 8b3e259

Browse files
committed
Allow RESP empty array
1 parent 6c54c27 commit 8b3e259

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/ext/readerResp.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,10 @@ static RespRes readRespReplyBulkArray(RespReaderCtx *ctx, RespReplyBuff *buffInf
299299
return RESP_REPLY_ERR;
300300
}
301301

302+
/* if empty array then jump to READ_END of array */
302303
if (ctx->numBulksArray == 0) {
303-
snprintf(ctx->errorMsg, sizeof(ctx->errorMsg), "Bulk Array must be bigger than zero");
304-
return RESP_REPLY_ERR;
304+
ctx->typeArrayState = READ_END;
305+
break;
305306
}
306307

307308
ctx->typeArrayState = READ_NEXT_BULK_HDR;

test/test_resp_reader.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ static void test_reply_long_err_trimmed_by_report(void **state) {
118118
static void test_mixture_and_fragmented(void **state) {
119119
UNUSED(state);
120120
RespRes res;
121-
int expReplies = 5;
122-
char bulk[] = "*3\r\n$2\r\n12\r\n$1\r\nA\r\n$3\r\nABC\r\n"
121+
int expReplies = 6;
122+
char bulk[] = "*0\r\n*3\r\n$2\r\n12\r\n$1\r\nA\r\n$3\r\nABC\r\n"
123123
"+OK\r\n$5\r\nmylib\r\n+OK\r\n+OK\r\n";
124124
RespReaderCtx ctx;
125125

0 commit comments

Comments
 (0)