@@ -483,7 +483,7 @@ robj *lookupStringForBitCommand(client *c, size_t maxbit) {
483483 o = createObject (OBJ_STRING ,sdsnewlen (NULL , byte + 1 ));
484484 dbAdd (c -> db ,c -> argv [1 ],o );
485485 } else {
486- if (checkType (c ,o , OBJ_STRING )) return NULL ;
486+ if (checkTypeStringvariant (c ,o )) return NULL ;
487487 o = dbUnshareStringValue (c -> db ,c -> argv [1 ],o );
488488 o -> ptr = sdsgrowzero (o -> ptr ,byte + 1 );
489489 }
@@ -504,7 +504,7 @@ robj *lookupStringForBitCommand(client *c, size_t maxbit) {
504504 * If the source object is NULL the function is guaranteed to return NULL
505505 * and set 'len' to 0. */
506506unsigned char * getObjectReadOnlyString (robj * o , long * len , char * llbuf ) {
507- serverAssert (o -> type == OBJ_STRING );
507+ serverAssert (o -> type == OBJ_STRING || o -> type == OBJ_STRING_PMEM );
508508 unsigned char * p = NULL ;
509509
510510 /* Set the 'p' pointer to the string, that can be just a stack allocated
@@ -572,7 +572,7 @@ void getbitCommand(client *c) {
572572 return ;
573573
574574 if ((o = lookupKeyReadOrReply (c ,c -> argv [1 ],shared .czero )) == NULL ||
575- checkType (c ,o , OBJ_STRING )) return ;
575+ checkTypeStringvariant (c ,o )) return ;
576576
577577 byte = bitoffset >> 3 ;
578578 bit = 7 - (bitoffset & 0x7 );
@@ -635,7 +635,7 @@ void bitopCommand(client *c) {
635635 continue ;
636636 }
637637 /* Return an error if one of the keys is not a string. */
638- if (checkType (c ,o , OBJ_STRING )) {
638+ if (checkTypeStringvariant (c ,o )) {
639639 unsigned long i ;
640640 for (i = 0 ; i < j ; i ++ ) {
641641 if (objects [i ])
@@ -774,7 +774,7 @@ void bitcountCommand(client *c) {
774774
775775 /* Lookup, check for type, and return 0 for non existing keys. */
776776 if ((o = lookupKeyReadOrReply (c ,c -> argv [1 ],shared .czero )) == NULL ||
777- checkType (c ,o , OBJ_STRING )) return ;
777+ checkTypeStringvariant (c ,o )) return ;
778778 p = getObjectReadOnlyString (o ,& strlen ,llbuf );
779779
780780 /* Parse start/end range if any. */
@@ -838,7 +838,7 @@ void bitposCommand(client *c) {
838838 addReplyLongLong (c , bit ? -1 : 0 );
839839 return ;
840840 }
841- if (checkType (c ,o , OBJ_STRING )) return ;
841+ if (checkTypeStringvariant (c ,o )) return ;
842842 p = getObjectReadOnlyString (o ,& strlen ,llbuf );
843843
844844 /* Parse start/end range if any. */
@@ -1000,7 +1000,7 @@ void bitfieldGeneric(client *c, int flags) {
10001000 /* Lookup for read is ok if key doesn't exit, but errors
10011001 * if it's not a string. */
10021002 o = lookupKeyRead (c -> db ,c -> argv [1 ]);
1003- if (o != NULL && checkType (c ,o , OBJ_STRING )) {
1003+ if (o != NULL && checkTypeStringvariant (c ,o )) {
10041004 zfree (ops );
10051005 return ;
10061006 }
0 commit comments