GNOME Bugzilla – Bug 728108
Potentially freeing uninitialized pointer
Last modified: 2018-04-13 14:24:36 UTC
See attached patch. Latest gcc correctly complains: gdatetime.c: In function 'g_date_time_format_locale': gdatetime.c:2377:8: warning: 'tmp' may be used uninitialized in this function [-Wmaybe-uninitialized] g_free (tmp); Ok to push?
Created attachment 274196 [details] [review] 0001-glib-Make-sure-to-not-free-an-uninitialized-pointer.patch
Maybe just do the = NULL in the initialiser? After looking at the code, the warning seems to be spurious since we only use 'tmp' under if (!locale_is_utf8) and within each case it seems that we always assign it before using it...
Review of attachment 274196 [details] [review]: (In reply to Allison Lortie (desrt) (extended vacation) from comment #2) > Maybe just do the = NULL in the initialiser? After looking at the code, the > warning seems to be spurious since we only use 'tmp' under if > (!locale_is_utf8) and within each case it seems that we always assign it > before using it... Marking as needs-work accordingly.
Created attachment 370856 [details] [review] gdatetime: Fix a spurious gcc warning It’s possible to get a -Wmaybe-uninitialized warning out of this code with some GCC versions. Rework the code to avoid needing the conditional free. Signed-off-by: Philip Withnall <withnall@endlessm.com>
Review of attachment 370856 [details] [review]: Okay
Attachment 370856 [details] pushed as a80117c - gdatetime: Fix a spurious gcc warning