From: Pieter Noordhuis Date: Fri, 21 May 2010 12:11:09 +0000 (+0200) Subject: check if *value is non-NULL before setting it X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/33c1269efc86a603c54c1045edc9402488a7224f?hp=335d16bc0f8f18f0da929bf3be725b42287c1042 check if *value is non-NULL before setting it --- diff --git a/ziplist.c b/ziplist.c index fefdbb7e..a754e0fb 100644 --- a/ziplist.c +++ b/ziplist.c @@ -87,13 +87,13 @@ unsigned char *ziplistPush(unsigned char *zl, unsigned char *entry, unsigned int unsigned char *ziplistPop(unsigned char *zl, sds *value, int where) { unsigned int curlen = ZIPLIST_BYTES(zl), len, rlen; unsigned char *p; - *value = NULL; + if (value) *value = NULL; /* Get pointer to element to remove */ p = (where == ZIPLIST_HEAD) ? ziplistHead(zl) : ziplistTail(zl); if (*p == ZIP_END) return zl; len = zipDecodeLength(p); - *value = sdsnewlen(p+zipEncodeLength(NULL,len),len); + if (value) *value = sdsnewlen(p+zipEncodeLength(NULL,len),len); /* Move list to front when popping from the head */ rlen = zipRawEntryLength(p);