Module Name:    src
Committed By:   snj
Date:           Mon Dec 12 07:25:16 UTC 2016

Modified Files:
        src/lib/libc/stdio [netbsd-7-0]: funopen.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1303):
        lib/libc/stdio/funopen.c: revision 1.15
PR/51572: calling funopen on each printw call is a tad excessive, but this
is not a reason for funopen to leak. Always call the close function since we
are indirecting through our cookie and we need to free it.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.14.12.1 src/lib/libc/stdio/funopen.c

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

Modified files:

Index: src/lib/libc/stdio/funopen.c
diff -u src/lib/libc/stdio/funopen.c:1.14 src/lib/libc/stdio/funopen.c:1.14.12.1
--- src/lib/libc/stdio/funopen.c:1.14	Wed Mar 28 15:21:11 2012
+++ src/lib/libc/stdio/funopen.c	Mon Dec 12 07:25:16 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: funopen.c,v 1.14 2012/03/28 15:21:11 christos Exp $	*/
+/*	$NetBSD: funopen.c,v 1.14.12.1 2016/12/12 07:25:16 snj Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)funopen.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: funopen.c,v 1.14 2012/03/28 15:21:11 christos Exp $");
+__RCSID("$NetBSD: funopen.c,v 1.14.12.1 2016/12/12 07:25:16 snj Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -138,6 +138,8 @@ cclosefn(void *dookie)
 	void *c = d->cookie;
 	int (*cf)(void *) = d->closefn;
 	free(dookie);
+	if (cf == NULL)
+		return 0;
 	return (*cf)(c);
 }
 
@@ -163,8 +165,7 @@ funopen(const void *cookie,
 	    d->readfn ? creadfn : NULL,
 	    d->writefn ? cwritefn : NULL,
 	    d->seekfn ? cseekfn : NULL,
-	    NULL,
-	    d->closefn ? cclosefn : NULL);
+	    NULL, cclosefn);
 	if (fp != NULL)
 		return fp;
 	free(d);

Reply via email to