Fix crash due to wrong use of the gpointer source (which is a
authorColin Leroy <colin@colino.net>
Mon, 17 Mar 2014 13:59:54 +0000 (14:59 +0100)
committerColin Leroy <colin@colino.net>
Mon, 17 Mar 2014 13:59:54 +0000 (14:59 +0100)
pointer-to-pointer to GList), replace exit() with return.

src/plugins/pgpcore/autocompletion.c

index ea3427a3a96da737689127d65816f7c8d2aefc8b..c64c63a4966ed076c527cd265644ee284063b874 100644 (file)
@@ -39,6 +39,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
        gpgme_error_t err;
        gpgme_user_id_t uid;
        address_entry *ae;
+       GList *addr_list = NULL;
 
        /* just return if autocompletion is disabled */
        if (!prefs_gpg_get_config()->autocompletion)
@@ -75,7 +76,7 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
 
                                                ae->grp_emails = NULL;
 
-                                               source = g_list_prepend(source, ae);
+                                               addr_list = g_list_prepend(addr_list, ae);
 
                                                debug_print("%s <%s>\n", uid->name, uid->email);
                                        }
@@ -89,8 +90,9 @@ static gboolean pgp_autocompletion_hook(gpointer source, gpointer data)
 
        if (gpg_err_code(err) != GPG_ERR_EOF) {
                debug_print("can not list keys: %s\n", gpgme_strerror(err));
-               exit(EXIT_FAILURE);
+               return EXIT_FAILURE;
        }
+       *((GList **)source) = addr_list;
 
        return EXIT_SUCCESS;
 }