Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Fix memory leak (found by MKSANITIZER=yes b...



details:   https://anonhg.NetBSD.org/src/rev/d5ffe408770c
branches:  trunk
changeset: 453575:d5ffe408770c
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Aug 18 11:11:48 2019 +0000

description:
Fix memory leak (found by MKSANITIZER=yes build).

diffstat:

 usr.sbin/sysinst/checkrc.c |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (31 lines):

diff -r 55ab01d3534c -r d5ffe408770c usr.sbin/sysinst/checkrc.c
--- a/usr.sbin/sysinst/checkrc.c        Sun Aug 18 11:08:56 2019 +0000
+++ b/usr.sbin/sysinst/checkrc.c        Sun Aug 18 11:11:48 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: checkrc.c,v 1.1 2014/07/26 19:30:44 dholland Exp $ */
+/* $NetBSD: checkrc.c,v 1.2 2019/08/18 11:11:48 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -81,6 +81,7 @@
 check(const char *varname, int filetocheck)
 {
        char *buf;
+       int rv;
 
        create_script(varname, filetocheck);
 
@@ -98,10 +99,9 @@
                fflush(logfp);
        }
 
-       if (strncmp(buf, "YES", strlen("YES")) == 0)
-               return 1;
-       else
-               return 0;
+       rv = strncmp(buf, "YES", strlen("YES")) == 0;
+       free(buf);
+       return rv;
 }
 
 int



Home | Main Index | Thread Index | Old Index