summaryrefslogtreecommitdiffstatshomepage
path: root/py/qstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/qstr.c')
-rw-r--r--py/qstr.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/qstr.c b/py/qstr.c
index e4b5c111b5..990ff37727 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -35,7 +35,12 @@ machine_uint_t qstr_compute_hash(const byte *data, uint len) {
for (const byte *top = data + len; data < top; data++) {
hash = ((hash << 5) + hash) ^ (*data); // hash * 33 ^ data
}
- return hash & 0xffff;
+ hash &= 0xffff;
+ // Make sure that valid hash is never zero, zero means "hash not computed"
+ if (hash == 0) {
+ hash++;
+ }
+ return hash;
}
typedef struct _qstr_pool_t {