libtasn1-commit
[Top][All Lists]
Advanced

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

[SCM] GNU libtasn1 branch, master, updated. libtasn1_4.7-15-g0301945


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_4.7-15-g0301945
Date: Mon, 04 Apr 2016 12:37:24 +0000

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 "GNU libtasn1".

http://git.savannah.gnu.org/cgit/libtasn1.git/commit/?id=0301945a0f1e33ff9e02175c7848fc7c0a91b6db

The branch, master has been updated
       via  0301945a0f1e33ff9e02175c7848fc7c0a91b6db (commit)
      from  4633168cd5ab694a053e4ee433f999f8e82c1f47 (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 0301945a0f1e33ff9e02175c7848fc7c0a91b6db
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Apr 4 14:36:07 2016 +0200

    use a safer variant of realloc
    
    This variant does not create memory leaks if allocation fails.
    Report and initial patch by Pascal Cuoq.

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

Summary of changes:
 lib/decoding.c   |    4 ++--
 lib/int.h        |   16 ++++++++++++++++
 lib/parser_aux.c |    4 ++--
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/lib/decoding.c b/lib/decoding.c
index 3f459f2..4fa045c 100644
--- a/lib/decoding.c
+++ b/lib/decoding.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2002-2014 Free Software Foundation, Inc.
+ * Copyright (C) 2002-2016 Free Software Foundation, Inc.
  *
  * This file is part of LIBTASN1.
  *
@@ -2193,7 +2193,7 @@ asn1_decode_simple_der (unsigned int etype, const 
unsigned char *der,
 
 static int append(uint8_t **dst, unsigned *dst_size, const unsigned char *src, 
unsigned src_size)
 {
-  *dst = realloc(*dst, *dst_size+src_size);
+  *dst = _asn1_realloc(*dst, *dst_size+src_size);
   if (*dst == NULL)
     return ASN1_MEM_ERROR;
   memcpy(*dst + *dst_size, src, src_size);
diff --git a/lib/int.h b/lib/int.h
index 322b80f..a3e890d 100644
--- a/lib/int.h
+++ b/lib/int.h
@@ -197,4 +197,20 @@ convert_old_type (unsigned int ntype)
     return ntype;
 }
 
+static inline
+void *_asn1_realloc(void *ptr, size_t size)
+{
+  void *ret;
+
+  if (size == 0)
+    return ptr;
+
+  ret = realloc(ptr, size);
+  if (ret == NULL)
+    {
+      free(ptr);
+    }
+  return ret;
+}
+
 #endif /* INT_H */
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index 8e85bf8..0a1f645 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2000-2014 Free Software Foundation, Inc.
+ * Copyright (C) 2000-2016 Free Software Foundation, Inc.
  *
  * This file is part of LIBTASN1.
  *
@@ -321,7 +321,7 @@ _asn1_append_value (asn1_node node, const void *value, 
unsigned int len)
       /* value is allocated */
       int prev_len = node->value_len;
       node->value_len += len;
-      node->value = realloc (node->value, node->value_len);
+      node->value = _asn1_realloc (node->value, node->value_len);
       if (node->value == NULL)
        {
          node->value_len = 0;


hooks/post-receive
-- 
GNU libtasn1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]