[git] GPGME - branch, master, updated. gpgme-1.12.0-124-g7f24233

[email protected] (by Werner Koch) Fri, 25 Jan 2019 13:46:03 +0100
Newsgroups gmane.comp.encryption.gpg.cvs
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG Made Easy".

The branch, master has been updated
       via  7f2423371964263784252cf839269023b6573bd2 (commit)
      from  66bcb8acb2452cf19318023ed0ff1ea7d7bb8439 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 7f2423371964263784252cf839269023b6573bd2
Author: Werner Koch <[email protected]>
Date:   Fri Jan 25 13:31:47 2019 +0100

    json: Fix minor memory leaks.
    
    * src/gpgme-json.c (interactive_repl): Fix memleak.
    (subkey_to_json): Ditto
    (op_config): Delay init of j_comps to avoid a leak on error.
    --
    
    GnuPG-bug-id: 4341, 4342, 4343
    Signed-off-by: Werner Koch <[email protected]>

diff --git a/src/gpgme-json.c b/src/gpgme-json.c
index e4ae81d..232bc50 100644
--- a/src/gpgme-json.c
+++ b/src/gpgme-json.c
@@ -1003,6 +1003,7 @@ static cjson_t
 subkey_to_json (gpgme_subkey_t sub)
 {
   cjson_t result = xjson_CreateObject ();
+  char *tmp;
 
   xjson_AddBoolToObject (result, "revoked", sub->revoked);
   xjson_AddBoolToObject (result, "expired", sub->expired);
@@ -1016,11 +1017,13 @@ subkey_to_json (gpgme_subkey_t sub)
   xjson_AddBoolToObject (result, "is_qualified", sub->is_qualified);
   xjson_AddBoolToObject (result, "is_cardkey", sub->is_cardkey);
   xjson_AddBoolToObject (result, "is_de_vs", sub->is_de_vs);
-
   xjson_AddStringToObject0 (result, "pubkey_algo_name",
                             gpgme_pubkey_algo_name (sub->pubkey_algo));
-  xjson_AddStringToObject0 (result, "pubkey_algo_string",
-                            gpgme_pubkey_algo_string (sub));
+
+  tmp = gpgme_pubkey_algo_string (sub);
+  xjson_AddStringToObject0 (result, "pubkey_algo_string", tmp);
+  xfree (tmp);
+
   xjson_AddStringToObject0 (result, "keyid", sub->keyid);
   xjson_AddStringToObject0 (result, "card_number", sub->card_number);
   xjson_AddStringToObject0 (result, "curve", sub->curve);
@@ -2925,7 +2928,7 @@ op_config (cjson_t request, cjson_t result)
   gpgme_conf_comp_t comp = NULL;
   cjson_t j_tmp;
   char *comp_name = NULL;
-  cjson_t j_comps = xjson_CreateArray ();
+  cjson_t j_comps;
 
   ctx = get_context (GPGME_PROTOCOL_GPGCONF);
 
@@ -2947,6 +2950,7 @@ op_config (cjson_t request, cjson_t result)
       goto leave;
     }
 
+  j_comps = xjson_CreateArray ();
   comp = conf;
   for (comp = conf; comp; comp = comp->next)
     {
@@ -2959,7 +2963,7 @@ op_config (cjson_t request, cjson_t result)
     }
   xjson_AddItemToObject (result, "components", j_comps);
 
-leave:
+ leave:
   gpgme_conf_release (conf);
   release_context (ctx);
 
@@ -3563,7 +3567,11 @@ interactive_repl (void)
           if (!request)
             request = xstrdup (line);
           else
-            request = xstrconcat (request, "\n", line, NULL);
+            {
+              char *tmp = xstrconcat (request, "\n", line, NULL);
+              xfree (request);
+              request = tmp;
+            }
         }
 
       if (!line)

-----------------------------------------------------------------------

Summary of changes:
 src/gpgme-json.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
GnuPG Made Easy
http://git.gnupg.org