Module Name:    src
Committed By:   roy
Date:           Wed Oct 14 20:54:51 UTC 2009

Modified Files:
        src/lib/libc/stdio: fgetstr.c

Log Message:
Store the allocated buffer against FILE, plugging a memory leak.
Fixes PR bin/42183.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/lib/libc/stdio/fgetstr.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/fgetstr.c
diff -u src/lib/libc/stdio/fgetstr.c:1.6 src/lib/libc/stdio/fgetstr.c:1.7
--- src/lib/libc/stdio/fgetstr.c:1.6	Thu Sep 24 20:38:53 2009
+++ src/lib/libc/stdio/fgetstr.c	Wed Oct 14 20:54:51 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fgetstr.c,v 1.6 2009/09/24 20:38:53 roy Exp $	*/
+/* $NetBSD: fgetstr.c,v 1.7 2009/10/14 20:54:51 roy Exp $	*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: fgetstr.c,v 1.6 2009/09/24 20:38:53 roy Exp $");
+__RCSID("$NetBSD: fgetstr.c,v 1.7 2009/10/14 20:54:51 roy Exp $");
 
 #include "namespace.h"
 
@@ -64,7 +64,10 @@
 		errno = EOVERFLOW;
 		goto error;
 	}
+	fp->_lb._base = (unsigned char *)p;
 	fp->_lb._size = (int)size;
+	if (*lenp == 0)
+		return NULL;
 	if (*lenp < SIZE_MAX)
 		return p;
 error:

Reply via email to