summaryrefslogtreecommitdiff
path: root/src/bitops.c
diff options
context:
space:
mode:
authororanagra <oran@redislabs.com>2016-05-24 14:52:43 +0300
committeroranagra <oran@redislabs.com>2016-05-24 14:52:43 +0300
commitc4433d2a6aa9deac835c1032d72622ca9d2aadc6 (patch)
tree622d29003018355171670020cdc717a7f8c016c6 /src/bitops.c
parent8c4f4d12d856e57534277c1737d7cb07890bbe63 (diff)
downloadredis-c4433d2a6aa9deac835c1032d72622ca9d2aadc6.tar.gz
fix crash in BITFIELD GET on non existing key or wrong type see #3259
this was a bug in the recent refactoring: bee963c4459223d874e3294a0d8638a588d33c8e
Diffstat (limited to 'src/bitops.c')
-rw-r--r--src/bitops.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/bitops.c b/src/bitops.c
index a7fad899f..a7e193f81 100644
--- a/src/bitops.c
+++ b/src/bitops.c
@@ -1049,12 +1049,14 @@ void bitfieldCommand(client *c) {
} else {
/* GET */
unsigned char buf[9];
- long strlen;
+ long strlen = 0;
unsigned char *src = NULL;
char llbuf[LONG_STR_SIZE];
- o = lookupKeyRead(c->db,c->argv[1]);
- src = getObjectReadOnlyString(o,&strlen,llbuf);
+ if ((o = lookupKeyRead(c->db,c->argv[1])) != NULL) {
+ if (checkType(c,o,OBJ_STRING)) continue;
+ src = getObjectReadOnlyString(o,&strlen,llbuf);
+ }
/* For GET we use a trick: before executing the operation
* copy up to 9 bytes to a local buffer, so that we can easily