Module Name:    src
Committed By:   martin
Date:           Sun Aug 18 11:11:48 UTC 2019

Modified Files:
        src/usr.sbin/sysinst: checkrc.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/checkrc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/checkrc.c
diff -u src/usr.sbin/sysinst/checkrc.c:1.1 src/usr.sbin/sysinst/checkrc.c:1.2
--- src/usr.sbin/sysinst/checkrc.c:1.1	Sat Jul 26 19:30:44 2014
+++ src/usr.sbin/sysinst/checkrc.c	Sun Aug 18 11:11:48 2019
@@ -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 @@ static int
 check(const char *varname, int filetocheck)
 {
 	char *buf;
+	int rv;
 
 	create_script(varname, filetocheck);
 
@@ -98,10 +99,9 @@ check(const char *varname, int filetoche
 		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

Reply via email to