]> git.saurik.com Git - apple/libc.git/blob - stdio/FreeBSD/fgetln.c.patch
Libc-763.11.tar.gz
[apple/libc.git] / stdio / FreeBSD / fgetln.c.patch
1 --- fgetln.c.orig 2010-07-09 13:54:22.000000000 -0700
2 +++ fgetln.c 2010-07-10 12:23:58.000000000 -0700
3 @@ -37,6 +37,7 @@ static char sccsid[] = "@(#)fgetln.c 8.2
4 __FBSDID("$FreeBSD: src/lib/libc/stdio/fgetln.c,v 1.11 2007/01/09 00:28:06 imp Exp $");
5
6 #include "namespace.h"
7 +#include <errno.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 @@ -61,6 +62,10 @@ __slbexpand(FILE *fp, size_t newsize)
12 #endif
13 if (fp->_lb._size >= newsize)
14 return (0);
15 + if (newsize > INT_MAX) {
16 + errno = ENOMEM;
17 + return (-1);
18 + }
19 if ((p = realloc(fp->_lb._base, newsize)) == NULL)
20 return (-1);
21 fp->_lb._base = p;
22 @@ -159,6 +164,7 @@ fgetln(FILE *fp, size_t *lenp)
23
24 error:
25 *lenp = 0; /* ??? */
26 + fp->_flags |= __SERR;
27 FUNLOCKFILE(fp);
28 return (NULL); /* ??? */
29 }