zigalenarcic / mangl

An enhanced man page viewer for linux and BSD systems based on OpenGL and mandoc libraries
Other
39 stars 7 forks source link

fix null pointer dereference when handling allocation failure #19

Closed Smattr closed 2 months ago

Smattr commented 2 months ago

When the malloc call in hashmap_new succeeded but then the later calloc call failed, the error logic would call hashmap_free that would dereference m->data. This occurred because m->table_size is not yet set and likely contains a non-zero value, despite m->data == NULL. This change avoids the situation by zeroing the initial memory, including m->table_size.

zigalenarcic commented 2 months ago

Thanks.