[Pkg-gnupg-commit] [gnupg2] 146/205: common: Add 'append_to_strlist_try' which can fail.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed May 11 08:38:31 UTC 2016


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gnupg2.

commit 95303ee11df12f284e98d02dba993eda9e425383
Author: Justus Winter <justus at g10code.com>
Date:   Thu Apr 21 12:36:04 2016 +0200

    common: Add 'append_to_strlist_try' which can fail.
    
    * common/strlist.c (append_to_strlist): Use the new function.
    (append_to_strlist_try): New function.
    * common/strlist.h (append_to_strlist_try): New prototype.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 common/strlist.c | 15 +++++++++++++++
 common/strlist.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/common/strlist.c b/common/strlist.c
index 760a460..2ba0209 100644
--- a/common/strlist.c
+++ b/common/strlist.c
@@ -112,9 +112,24 @@ add_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
 strlist_t
 append_to_strlist( strlist_t *list, const char *string )
 {
+  strlist_t sl;
+  sl = append_to_strlist_try (list, string);
+  if (sl == NULL)
+    abort ();
+  return sl;
+}
+
+
+/* Add STRING to the LIST at the end.  */
+strlist_t
+append_to_strlist_try (strlist_t *list, const char *string)
+{
     strlist_t r, sl;
 
     sl = xmalloc( sizeof *sl + strlen(string));
+    if (sl == NULL)
+      return NULL;
+
     sl->flags = 0;
     strcpy(sl->d, string);
     sl->next = NULL;
diff --git a/common/strlist.h b/common/strlist.h
index acb92f7..94dd32f 100644
--- a/common/strlist.h
+++ b/common/strlist.h
@@ -46,6 +46,7 @@ strlist_t add_to_strlist_try (strlist_t *list, const char *string);
 strlist_t add_to_strlist2( strlist_t *list, const char *string, int is_utf8);
 
 strlist_t append_to_strlist (strlist_t *list, const char *string);
+strlist_t append_to_strlist_try (strlist_t *list, const char *string);
 strlist_t append_to_strlist2 (strlist_t *list, const char *string,
                               int is_utf8);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list