summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlya Shipitsin <chipitsine@gmail.com>2021-10-17 18:48:15 +0300
committerGitHub <noreply@github.com>2021-10-17 18:48:15 +0300
commit94fded4f4f9c3d52d69969c4a2a9d82786a3ac16 (patch)
treeebdeb44dae1cbfe3df60872ce655e030e7239421
parent61bb04415614f4b99002cc6c6a31ef5019881b07 (diff)
downloadredis-94fded4f4f9c3d52d69969c4a2a9d82786a3ac16.tar.gz
Code cleanup, resolve an issue identified by cppcheck (#4373)
[src/bitops.c:512] -> [src/bitops.c:507]: (warning) Either the condition 'if(o&&o->encoding==1)' is redundant or there is possible null pointer dereference: o. This function has checks for `o` to be null or non-null, so it is odd that it accesses it first..
-rw-r--r--src/bitops.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/bitops.c b/src/bitops.c
index 435ab7a33..5190e1035 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -508,7 +508,7 @@ robj *lookupStringForBitCommand(client *c, uint64_t maxbit, int *created) {
* If the source object is NULL the function is guaranteed to return NULL
* and set 'len' to 0. */
unsigned char *getObjectReadOnlyString(robj *o, long *len, char *llbuf) {
- serverAssert(o->type == OBJ_STRING);
+ serverAssert(!o || o->type == OBJ_STRING);
unsigned char *p = NULL;
/* Set the 'p' pointer to the string, that can be just a stack allocated