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 788158 - info: Use g_auto to reduce memory leaks
info: Use g_auto to reduce memory leaks
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Other Preferences
git master
Other Linux
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-09-25 20:56 UTC by Robert Ancell
Modified: 2018-01-23 02:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
info: Use g_auto for variables (25.57 KB, patch)
2017-09-25 20:56 UTC, Robert Ancell
none Details | Review
info: Use g_auto for variables (27.27 KB, patch)
2017-09-25 20:59 UTC, Robert Ancell
none Details | Review
info: Use g_auto for variables (26.03 KB, patch)
2018-01-21 23:29 UTC, Robert Ancell
none Details | Review
nfo: Use g_auto for variables (26.38 KB, patch)
2018-01-23 01:58 UTC, Robert Ancell
none Details | Review
info: Use g_auto for variables (26.39 KB, patch)
2018-01-23 02:00 UTC, Robert Ancell
committed Details | Review

Description Robert Ancell 2017-09-25 20:56:10 UTC
Created attachment 360385 [details] [review]
info: Use g_auto for variables

Use the g_auto macros to reduce memory leaks. There were a couple found making this patch.
Comment 1 Robert Ancell 2017-09-25 20:59:41 UTC
Created attachment 360386 [details] [review]
info: Use g_auto for variables

Missed some g_strfreev.
Comment 2 Georges Basile Stavracas Neto 2018-01-21 14:17:45 UTC
Review of attachment 360386 [details] [review]:

Hi Robert, thanks for your patch. Could you please update it to the latest master? It does not apply cleanly anymore.
Comment 3 Robert Ancell 2018-01-21 23:29:24 UTC
Created attachment 367190 [details] [review]
info: Use g_auto for variables

Rebased on master
Comment 4 Georges Basile Stavracas Neto 2018-01-23 00:47:24 UTC
Review of attachment 367190 [details] [review]:

Two other comments. Besides them, the patch looks pretty good.

::: panels/info/cc-info-default-apps-panel.c
@@ -93,1 @@
       error = NULL;

Hm... I think this might be a memory leak. I think this was a valid case of autoptr + free. If you set to NULL but not free, when the block ends, nothing will be freed where it clearly should.

::: panels/info/info-cleanup.c
@@ +95,3 @@
+  char *new;
+  g_autoptr(GRegex) re = NULL;
+  g_autoptr(GError) error = NULL;

Could change to 'gchar' since you're already touching it.
Comment 5 Robert Ancell 2018-01-23 01:58:26 UTC
Created attachment 367270 [details] [review]
nfo: Use g_auto for variables

Fixed up issues as requested and tided up some other uses of GError and char *.
Comment 6 Robert Ancell 2018-01-23 02:00:29 UTC
Created attachment 367271 [details] [review]
info: Use g_auto for variables

Typo in previous commit
Comment 7 Georges Basile Stavracas Neto 2018-01-23 02:30:19 UTC
Thanks! Push with a minor correction (the second GError should be called 'local_error' to avoid shadowing the first one.)

Attachment 367271 [details] pushed as 1e62c99 - info: Use g_auto for variables