From fe359cbfc25f4ada01e314ee4bb123b744422c62 Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Sun, 15 Aug 2021 21:37:44 +0300 Subject: [PATCH] Fix: don't assume char is unsigned. (#9375) On systems that have unsigned char by default (s390x, arm), redis-server could crash as soon as it populates the command table. --- src/dict.c | 6 +++--- src/dict.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dict.c b/src/dict.c index bc03b0c96e..a26ba9eba0 100644 --- a/src/dict.c +++ b/src/dict.c @@ -61,7 +61,7 @@ static unsigned int dict_force_resize_ratio = 5; /* -------------------------- private prototypes ---------------------------- */ static int _dictExpandIfNeeded(dict *d); -static char _dictNextExp(unsigned long size); +static signed char _dictNextExp(unsigned long size); static long _dictKeyIndex(dict *d, const void *key, uint64_t hash, dictEntry **existing); static int _dictInit(dict *d, dictType *type); @@ -150,7 +150,7 @@ int _dictExpand(dict *d, unsigned long size, int* malloc_failed) /* the new hash table */ dictEntry **new_ht_table; unsigned long new_ht_used; - char new_ht_size_exp = _dictNextExp(size); + signed char new_ht_size_exp = _dictNextExp(size); /* Detect overflows */ size_t newsize = 1ul<0 rehashing is paused (<0 indicates coding error) */ - char ht_size_exp[2]; /* exponent of size. (size = 1<