Source-Changes-HG archive

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

[src/trunk]: src/lib/libc/stdio Store the allocated buffer against FILE, plug...



details:   https://anonhg.NetBSD.org/src/rev/c75e70b66b36
branches:  trunk
changeset: 748140:c75e70b66b36
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Oct 14 20:54:51 2009 +0000

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

diffstat:

 lib/libc/stdio/fgetstr.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r d488504f35ae -r c75e70b66b36 lib/libc/stdio/fgetstr.c
--- a/lib/libc/stdio/fgetstr.c  Wed Oct 14 19:25:39 2009 +0000
+++ b/lib/libc/stdio/fgetstr.c  Wed Oct 14 20:54:51 2009 +0000
@@ -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:



Home | Main Index | Thread Index | Old Index