X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/5fc669295655ec0eea7722aa4a48921dc6b700ec..003db17f7a36a8098827f40df8fedc087b5a26f6:/lunaix-os/libs/hash.c?ds=inline diff --git a/lunaix-os/libs/hash.c b/lunaix-os/libs/hash.c index 293ec67..c1580ed 100644 --- a/lunaix-os/libs/hash.c +++ b/lunaix-os/libs/hash.c @@ -11,10 +11,13 @@ uint32_t strhash_32(unsigned char* str, uint32_t truncate_to) { + if (!str) + return 0; + uint32_t hash = 5381; int c; - while (c = *str++) + while ((c = *str++)) hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ return hash >> (HASH_SIZE_BITS - truncate_to);