[gnome-bluetooth/wip/hadess/fix-memory-leaks: 2/2] pairing-dialog: Fix uninitialised variable



commit e07975096ee672690157401de8315aa8576ddaf9
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Nov 21 15:50:48 2019 +0100

    pairing-dialog: Fix uninitialised variable
    
    lib/bluetooth-pairing-dialog.c: In function ‘bluetooth_pairing_dialog_set_mode’:
    include/glib-2.0/glib/gmacros.h:928:7: warning: ‘help’ may be used uninitialized in this function 
[-Wmaybe-uninitialized]
      928 |    if (expr)                                    \
          |       ^
    lib/bluetooth-pairing-dialog.c:69:8: note: ‘help’ was declared here
       69 |  char *help;
          |        ^~~~

 lib/bluetooth-pairing-dialog.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
---
diff --git a/lib/bluetooth-pairing-dialog.c b/lib/bluetooth-pairing-dialog.c
index 4565eeb0..704f6ff9 100644
--- a/lib/bluetooth-pairing-dialog.c
+++ b/lib/bluetooth-pairing-dialog.c
@@ -65,8 +65,8 @@ bluetooth_pairing_dialog_set_mode (BluetoothPairingDialog *self,
                                   const char             *device_name)
 {
        BluetoothPairingDialogPrivate *priv = BLUETOOTH_PAIRING_DIALOG_GET_PRIVATE (self);
-       char *title;
-       char *help;
+       g_autofree char *title = NULL;
+       g_autofree char *help = NULL;
        GtkStyleContext *context;
 
        priv->mode = mode;
@@ -159,8 +159,6 @@ bluetooth_pairing_dialog_set_mode (BluetoothPairingDialog *self,
 
        gtk_label_set_text (GTK_LABEL (priv->title), title);
        gtk_label_set_text (GTK_LABEL (priv->help_label), help);
-       g_free (title);
-       g_free (help);
 }
 
 BluetoothPairingMode


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]