fix crash in BITFIELD GET on non existing key or wrong type see #3259

this was a bug in the recent refactoring: bee963c445
This commit is contained in:
oranagra
2016-05-24 14:52:43 +03:00
committed by antirez
parent 26555f5e00
commit a2e27b810e

View File

@ -1060,12 +1060,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]);
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