Source-Changes-HG archive

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

[src/trunk]: src/lib/libexecinfo fix cleanup on error



details:   https://anonhg.NetBSD.org/src/rev/d3f715960110
branches:  trunk
changeset: 780044:d3f715960110
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jul 09 03:11:59 2012 +0000

description:
fix cleanup on error

diffstat:

 lib/libexecinfo/backtrace.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (45 lines):

diff -r ce101702c95b -r d3f715960110 lib/libexecinfo/backtrace.c
--- a/lib/libexecinfo/backtrace.c       Sun Jul 08 23:18:23 2012 +0000
+++ b/lib/libexecinfo/backtrace.c       Mon Jul 09 03:11:59 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: backtrace.c,v 1.1 2012/05/26 22:02:29 christos Exp $   */
+/*     $NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $   */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: backtrace.c,v 1.1 2012/05/26 22:02:29 christos Exp $");
+__RCSID("$NetBSD: backtrace.c,v 1.2 2012/07/09 03:11:59 christos Exp $");
 
 #include <sys/param.h>
 #include <assert.h>
@@ -168,7 +168,7 @@
                st = NULL;
 
        if ((ptr = calloc(len, slen)) == NULL)
-               return NULL;
+               goto out;
 
        size_t psize = len * slen;
        size_t offs = len * sizeof(char *);
@@ -180,7 +180,8 @@
                x = format_address(st, &ptr, &psize, offs, fmt, trace[i]);
                if (x == -1) {
                        free(ptr);
-                       return NULL;
+                       ptr = NULL;
+                       goto out;
                }
                offs += x;
                ptr[offs++] = '\0';
@@ -191,6 +192,7 @@
        for (size_t j = 0; j < len; j++)
                ((char **)(void *)ptr)[j] += (intptr_t)ptr;
 
+out:
        symtab_destroy(st);
        if (fd != -1)
                (void)close(fd);



Home | Main Index | Thread Index | Old Index