mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
ziplistNext should work as expected when called with a pointer to ZIP_END
This commit is contained in:
parent
a03611e133
commit
d71b98650f
11
ziplist.c
11
ziplist.c
@ -430,7 +430,16 @@ unsigned char *ziplistIndex(unsigned char *zl, int index) {
|
|||||||
/* Return pointer to next entry in ziplist. */
|
/* Return pointer to next entry in ziplist. */
|
||||||
unsigned char *ziplistNext(unsigned char *zl, unsigned char *p) {
|
unsigned char *ziplistNext(unsigned char *zl, unsigned char *p) {
|
||||||
((void) zl);
|
((void) zl);
|
||||||
return (p[0] == ZIP_END) ? NULL : p+zipRawEntryLength(p);
|
|
||||||
|
/* "p" could be equal to ZIP_END, caused by ziplistDelete,
|
||||||
|
* and we should return NULL. Otherwise, we should return NULL
|
||||||
|
* when the *next* element is ZIP_END (there is no next entry). */
|
||||||
|
if (p[0] == ZIP_END) {
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
p = p+zipRawEntryLength(p);
|
||||||
|
return (p[0] == ZIP_END) ? NULL : p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return pointer to previous entry in ziplist. */
|
/* Return pointer to previous entry in ziplist. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user