Skip to content

Commit

Permalink
Allow RESP empty array
Browse files Browse the repository at this point in the history
  • Loading branch information
moticless committed Apr 21, 2024
1 parent 6c54c27 commit 8b3e259
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/ext/readerResp.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,10 @@ static RespRes readRespReplyBulkArray(RespReaderCtx *ctx, RespReplyBuff *buffInf
return RESP_REPLY_ERR;
}

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

ctx->typeArrayState = READ_NEXT_BULK_HDR;
Expand Down
4 changes: 2 additions & 2 deletions test/test_resp_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ static void test_reply_long_err_trimmed_by_report(void **state) {
static void test_mixture_and_fragmented(void **state) {
UNUSED(state);
RespRes res;
int expReplies = 5;
char bulk[] = "*3\r\n$2\r\n12\r\n$1\r\nA\r\n$3\r\nABC\r\n"
int expReplies = 6;
char bulk[] = "*0\r\n*3\r\n$2\r\n12\r\n$1\r\nA\r\n$3\r\nABC\r\n"
"+OK\r\n$5\r\nmylib\r\n+OK\r\n+OK\r\n";
RespReaderCtx ctx;

Expand Down

0 comments on commit 8b3e259

Please sign in to comment.