[network-manager-applet] libnma: fix uninitialized variable in update_title() ("nma-cert-chooser-button.c")



commit 310958d541a519490f6471640715c8c496de97fe
Author: Thomas Haller <thaller redhat com>
Date:   Thu Mar 23 12:14:33 2017 +0100

    libnma: fix uninitialized variable in update_title() ("nma-cert-chooser-button.c")
    
    Fixes: 2644d631afd072f66878799e75c5aa1947510c7a
    
    Fixes "src/libnma/nma-cert-chooser-button.c:165:7: error: variable label is used uninitialized whenever 
if condition is false [-Werror,-Wsometimes-uninitialized]"

 src/libnma/nma-cert-chooser-button.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/src/libnma/nma-cert-chooser-button.c b/src/libnma/nma-cert-chooser-button.c
index bf83fc9..f7e4444 100644
--- a/src/libnma/nma-cert-chooser-button.c
+++ b/src/libnma/nma-cert-chooser-button.c
@@ -150,7 +150,7 @@ update_title (NMACertChooserButton *button)
        GckUriData *data;
        GtkTreeIter iter;
        GtkTreeModel *model;
-       gchar *label;
+       gs_free char *label = NULL;
        GError *error = NULL;
 
        model = gtk_combo_box_get_model (GTK_COMBO_BOX (button));
@@ -165,6 +165,7 @@ update_title (NMACertChooserButton *button)
                if (data) {
                        if (!gck_attributes_find_string (data->attributes, CKA_LABEL, &label)) {
                                if (data->token_info) {
+                                       g_free (label);
                                        label = g_strdup_printf (  priv->flags & 
NMA_CERT_CHOOSER_BUTTON_FLAG_KEY
                                                                 ? _("Key in %s")
                                                                 : _("Certificate in %s"),
@@ -185,11 +186,9 @@ update_title (NMACertChooserButton *button)
                label = g_strdup (label);
        }
 
-       if (!label)
-               label = g_strdup (_("(Unknown)"));
        gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-                           COLUMN_LABEL, label, -1);
-       g_free (label);
+                           COLUMN_LABEL, label ?: _("(Unknown)"),
+                           -1);
 }
 
 static void


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