Loading...
--- Libc/Libc-763.13/stdio/FreeBSD/asprintf.c.patch
+++ Libc/Libc-594.9.1/stdio/FreeBSD/asprintf.c.patch
@@ -1,32 +1,54 @@
---- asprintf.c.bsdnew 2009-11-11 19:15:16.000000000 -0800
-+++ asprintf.c 2009-11-11 19:15:42.000000000 -0800
-@@ -33,6 +33,8 @@
+--- asprintf.c.orig 2003-05-20 15:22:40.000000000 -0700
++++ asprintf.c 2005-02-23 16:17:23.000000000 -0800
+@@ -30,6 +30,8 @@
#include <sys/cdefs.h>
- __FBSDID("$FreeBSD: src/lib/libc/stdio/asprintf.c,v 1.15 2009/03/02 04:11:42 das Exp $");
+ __FBSDID("$FreeBSD: src/lib/libc/stdio/asprintf.c,v 1.13 2002/09/26 13:09:48 tjr Exp $");
+#include "xlocale_private.h"
+
#include <stdio.h>
- #include <stdarg.h>
-
-@@ -43,7 +45,19 @@ asprintf(char ** __restrict s, char cons
- va_list ap;
-
+ #include <stdlib.h>
+ #include <errno.h>
+@@ -57,7 +59,41 @@
+ f._extra = &ext;
+ INITEXTRA(&f);
va_start(ap, fmt);
-- ret = vasprintf(s, fmt, ap);
-+ ret = vasprintf_l(s, __current_locale(), fmt, ap);
+- ret = __vfprintf(&f, fmt, ap); /* Use unlocked __vfprintf */
++ ret = __vfprintf(&f, __current_locale(), fmt, ap); /* Use unlocked __vfprintf */
+ va_end(ap);
++ if (ret < 0) {
++ free(f._bf._base);
++ *str = NULL;
++ errno = ENOMEM;
++ return (-1);
++ }
++ *f._p = '\0';
++ *str = (char *)f._bf._base;
+ return (ret);
+}
+
+int
-+asprintf_l(char ** __restrict s, locale_t loc, char const * __restrict fmt, ...)
++asprintf_l(char **str, locale_t loc, char const *fmt, ...)
+{
+ int ret;
+ va_list ap;
++ FILE f;
++ struct __sFILEX ext;
+
++ NORMALIZE_LOCALE(loc);
++ f._file = -1;
++ f._flags = __SWR | __SSTR | __SALC;
++ f._bf._base = f._p = (unsigned char *)malloc(128);
++ if (f._bf._base == NULL) {
++ *str = NULL;
++ errno = ENOMEM;
++ return (-1);
++ }
++ f._bf._size = f._w = 127; /* Leave room for the NUL */
++ f._extra = &ext;
++ INITEXTRA(&f);
+ va_start(ap, fmt);
-+ ret = vasprintf_l(s, loc, fmt, ap);
++ ret = __vfprintf(&f, loc, fmt, ap); /* Use unlocked __vfprintf */
va_end(ap);
- return (ret);
- }
+ if (ret < 0) {
+ free(f._bf._base);