Make _intern_string_hash safe for ""

The loop was unnecessarily written in a way that fails
to terminate if len is 0 (ie for the empty string).
Avoid that by checking for len > 0 explicitly.
This commit is contained in:
Matthias Clasen 2017-09-17 10:16:48 -04:00 committed by Behdad Esfahbod
parent 903b0de539
commit d50dbbaf27

View file

@ -986,7 +986,7 @@ _intern_string_hash (const char *str, int len)
const signed char *p = (const signed char *) str;
unsigned int h = *p;
for (p += 1; --len; p++)
for (p += 1; len > 0; len--, p++)
h = (h << 5) - h + *p;
return h;