After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 728108 - Potentially freeing uninitialized pointer
Potentially freeing uninitialized pointer
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-04-13 09:46 UTC by Sebastian Dröge (slomo)
Modified: 2018-04-13 14:24 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
0001-glib-Make-sure-to-not-free-an-uninitialized-pointer.patch (1.78 KB, patch)
2014-04-13 09:47 UTC, Sebastian Dröge (slomo)
needs-work Details | Review
gdatetime: Fix a spurious gcc warning (1.25 KB, patch)
2018-04-12 12:22 UTC, Philip Withnall
committed Details | Review

Description Sebastian Dröge (slomo) 2014-04-13 09:46:40 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?
Comment 1 Sebastian Dröge (slomo) 2014-04-13 09:47:06 UTC
Created attachment 274196 [details] [review]
0001-glib-Make-sure-to-not-free-an-uninitialized-pointer.patch
Comment 2 Allison Karlitskaya (desrt) 2014-04-13 15:26:34 UTC
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...
Comment 3 Philip Withnall 2017-11-16 11:19:15 UTC
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.
Comment 4 Philip Withnall 2018-04-12 12:22:28 UTC
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>
Comment 5 Emmanuele Bassi (:ebassi) 2018-04-13 13:54:19 UTC
Review of attachment 370856 [details] [review]:

Okay
Comment 6 Philip Withnall 2018-04-13 14:24:30 UTC
Attachment 370856 [details] pushed as a80117c - gdatetime: Fix a spurious gcc warning