8000 Merge pull request #1837 from phpredis/issue-1794 · phpredis/phpredis@f5c6fb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5c6fb0

Browse files
authored
Merge pull request #1837 from phpredis/issue-1794
Issue #1794
2 parents 3645807 + 500916a commit f5c6fb0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

library.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,17 +1505,21 @@ redis_read_stream_messages(RedisSock *redis_sock, int count, zval *z_ret
15051505
* the multi-bulk header for field and values */
15061506
if ((read_mbulk_header(redis_sock, &mhdr) < 0 || mhdr != 2) ||
15071507
((id = redis_sock_read(redis_sock, &idlen)) == NULL) ||
1508-
(read_mbulk_header(redis_sock, &fields) < 0 || fields % 2 != 0))
1508+
(read_mbulk_header(redis_sock, &fields) < 0 ||
1509+
(fields > 0 && fields % 2 != 0)))
15091510
{
15101511
if (id) efree(id);
15111512
return -1;
15121513
}
15131514

1514-
array_init(&z_message);
1515-
1516-
redis_mbulk_reply_loop(redis_sock, &z_message, fields, UNSERIALIZE_VALS);
1517-
array_zip_values_and_scores(redis_sock, &z_message, SCORE_DECODE_NONE);
1518-
add_assoc_zval_ex(z_ret, id, idlen, &z_message);
1515+
if (fields < 0) {
1516+
add_assoc_null_ex(z_ret, id, idlen);
1517+
} else {
1518+
array_init(&z_message);
1519+
redis_mbulk_reply_loop(redis_sock, &z_message, fields, UNSERIALIZE_VALS);
1520+
array_zip_values_and_scores(redis_sock, &z_message, SCORE_DECODE_NONE);
1521+
add_assoc_zval_ex(z_ret, id, idlen, &z_message);
1522+
}
15191523
efree(id);
15201524
}
15211525

0 commit comments

Comments
 (0)
0