dunst-project / dunst

Lightweight and customizable notification daemon
https://dunst-project.org
Other
4.52k stars 338 forks source link

Add guard against realloc fail in icon-lookup.c #1170

Closed Costinteo closed 1 year ago

Costinteo commented 1 year ago

If realloc fails, its return value will be NULL. In the two calls to realloc in icon-lookup.c, this means the global icon_themes and default_themes_index will be overwritten, producing not only a probable error, but a memory leak as well.

This pull request aims to fix that by adding a couple of guards and keeping the global arrays intact, in case of failure.

Bugs found with cppcheck. It is really minor, I doubt it will ever happen. But it is in theory possible.

bebehei commented 1 year ago

Please just use g_realloc instead of alloc. Dunst heavily uses GLib and hence usually uses GLib's memory functions. These functions terminate upon allocation failure. (Dunst would not do anything else either)

Costinteo commented 1 year ago

Thank you for the reply! I will open a new pull request, so as to not add a commit fixing my initial commit, but rather one unique commit. Seems like changing the commit history does not update the pull request properly.