Module Name:    src
Committed By:   christos
Date:           Tue Mar  5 16:29:09 UTC 2013

Modified Files:
        src/tools/compat: dprintf.c

Log Message:
don't leak on error.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tools/compat/dprintf.c

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

Modified files:

Index: src/tools/compat/dprintf.c
diff -u src/tools/compat/dprintf.c:1.1 src/tools/compat/dprintf.c:1.2
--- src/tools/compat/dprintf.c:1.1	Tue Mar  5 11:26:41 2013
+++ src/tools/compat/dprintf.c	Tue Mar  5 11:29:09 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dprintf.c,v 1.1 2013/03/05 16:26:41 christos Exp $	*/
+/*	$NetBSD: dprintf.c,v 1.2 2013/03/05 16:29:09 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 NetBSD Foundation, Inc.
@@ -52,8 +52,10 @@ dprintf(int fd, const char *fmt, ...)
 	if ((e = dup(fd)) == -1)
 		return -1;
 
-	if ((fp = fdopen(e, "r+")) == NULL)
+	if ((fp = fdopen(e, "r+")) == NULL) {
+		(void)close(e);
 		return -1;
+	}
 
 	va_start(ap, fmt);
 	e = vfprintf(fp, fmt, ap);

Reply via email to