nicholastolent / Master-Godot

First Repository for Godot
MIT License
1 stars 2 forks source link

Using `HashMap::get` with a null value crashes the engine when the key type is `const char *` #4

Open nicholastolent opened 4 years ago

nicholastolent commented 4 years ago

Please select an issue you would like to work and document it here.

nicholastolent commented 4 years ago

Please start working on this!!!

gneustel2017 commented 4 years ago

https://github.com/godotengine/godot/issues/31463

static inline uint32_t hash_djb2(const char *p_cstr) {

const unsigned char *chr = (const unsigned char *)p_cstr; 
uint32_t hash = 5381; 
uint32_t c; 

while ((c = *chr++)) 
    hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ 

return hash; 

}

crashes when uses hash_djb2, doesn't check for NULL