Source-Changes-HG archive

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

[src/trunk]: src/lib/libterminfo PR/50092: Rin Okuyama: Fix memory leak.



details:   https://anonhg.NetBSD.org/src/rev/690569b0adf8
branches:  trunk
changeset: 341845:690569b0adf8
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Nov 25 18:46:24 2015 +0000

description:
PR/50092: Rin Okuyama: Fix memory leak.

diffstat:

 lib/libterminfo/termcap.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r 84d1c8987e0e -r 690569b0adf8 lib/libterminfo/termcap.c
--- a/lib/libterminfo/termcap.c Wed Nov 25 18:38:21 2015 +0000
+++ b/lib/libterminfo/termcap.c Wed Nov 25 18:46:24 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: termcap.c,v 1.17 2011/11/13 15:24:04 christos Exp $ */
+/* $NetBSD: termcap.c,v 1.18 2015/11/25 18:46:24 christos Exp $ */
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: termcap.c,v 1.17 2011/11/13 15:24:04 christos Exp $");
+__RCSID("$NetBSD: termcap.c,v 1.18 2015/11/25 18:46:24 christos Exp $");
 
 #include <assert.h>
 #include <ctype.h>
@@ -553,8 +553,11 @@
                        else
                                len += rl;
                        p = realloc(info, len);
-                       if (p == NULL)
+                       if (p == NULL) {
+                               if (fv == 1)
+                                       free(val);
                                return NULL;
+                       }
                        info = p;
                }
 



Home | Main Index | Thread Index | Old Index