GNOME Bugzilla – Bug 634146
Calls to g_win32_get_package_installation_directory_of_module() are never checked for NULL
Last modified: 2014-03-16 13:01:43 UTC
Created attachment 173935 [details] [review] Patch which fixes 2 possible NULL cases in _gtk_get_libdir I was experiencing a crash with GTK 2.22.0 cross compiled for Windows with MinGW on Linux when a GTK theme was included in etc/gtk-2.0/gtkrc. The private function _gtk_get_libdir is only built if G_OS_WIN32 is defined. A call to g_win32_get_package_installation_directory_of_module (gtk_dll) is made and strrchr was executed on the return value. Neither result was checked for NULL. A NULL value could get returned from g_win32_get_package_installation_directory_of_module(). A NULL value WILL get returned if GTK is in the root folder of a disk drive, causing a crash. Attached is a patch which checks for both cases.
Looking at the latest code there is now a check for the NULL that caused your crash. Looking a the g_win32_get_package_installation_directory_of_module() calls throughout gtkmain.c it doesnt look like the return value is ever checked for NULL.
The calls in gtkwin32.c (GTK3) don't check for NULL return values either.
Pushed to gtk-2-24: https://git.gnome.org/browse/gtk+/commit/?h=gtk-2-24&id=82310d48a8c9aedc39acc1b2bf6a89d0bb7de918