BUG: Cannot have an EMBSTR bigger than 255

Former-commit-id: e2d6e2d9d585cb7a73f469a8580f9cb0ec71a429
This commit is contained in:
John Sully 2020-08-15 23:30:22 +00:00
parent 82989540c4
commit 311b286d41

View File

@ -94,6 +94,7 @@ robj *createRawStringObject(const char *ptr, size_t len) {
* an object where the sds string is actually an unmodifiable string
* allocated in the same chunk as the object itself. */
robj *createEmbeddedStringObject(const char *ptr, size_t len) {
serverAssert(len <= UINT8_MAX);
size_t allocsize = sizeof(struct sdshdr8)+len+1;
if (allocsize < sizeof(void*))
allocsize = sizeof(void*);
@ -136,10 +137,10 @@ robj *createEmbeddedStringObject(const char *ptr, size_t len) {
#ifdef ENABLE_MVCC
#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 48
#else
#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 256
#define OBJ_ENCODING_EMBSTR_SIZE_LIMIT 56
#endif
//static_assert((sizeof(redisObject)+OBJ_ENCODING_EMBSTR_SIZE_LIMIT-8) == 64, "Max EMBSTR obj should be 64 bytes total");
static_assert((sizeof(redisObject)+OBJ_ENCODING_EMBSTR_SIZE_LIMIT-8) == 64, "Max EMBSTR obj should be 64 bytes total");
robj *createStringObject(const char *ptr, size_t len) {
if (len <= OBJ_ENCODING_EMBSTR_SIZE_LIMIT)
return createEmbeddedStringObject(ptr,len);