]> git.saurik.com Git - redis.git/commitdiff
check if *value is non-NULL before setting it
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 21 May 2010 12:11:09 +0000 (14:11 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Sat, 29 May 2010 19:10:15 +0000 (21:10 +0200)
ziplist.c

index fefdbb7e64da52394bfc0bf808a04ccd50b935df..a754e0fb6ff861b8126c7498e96356a702d73bc8 100644 (file)
--- 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);