Allow zero size with non-null buf in *asnprintf.
* libc/stdio/asnprintf.c (_asnprintf_r, asnprintf): Avoid free'ing user's buf. * libc/stdio/asniprintf.c (_asniprintf_r, asniprintf): Likewise. * libc/stdio/vasniprintf.c (_vasniprintf_r): Likewise. * libc/stdio/vasnprintf.c (_vasnprintf_r): Likewise.
This commit is contained in:
		| @@ -1,3 +1,12 @@ | |||||||
|  | 2007-05-09  Eric Blake  <ebb9@byu.net> | ||||||
|  |  | ||||||
|  | 	Allow zero size with non-null buf in *asnprintf. | ||||||
|  | 	* libc/stdio/asnprintf.c (_asnprintf_r, asnprintf): Avoid free'ing | ||||||
|  | 	user's buf. | ||||||
|  | 	* libc/stdio/asniprintf.c (_asniprintf_r, asniprintf): Likewise. | ||||||
|  | 	* libc/stdio/vasniprintf.c (_vasniprintf_r): Likewise. | ||||||
|  | 	* libc/stdio/vasnprintf.c (_vasnprintf_r): Likewise. | ||||||
|  |  | ||||||
| 2007-05-07  Charles Wilson  <cygwin@...> | 2007-05-07  Charles Wilson  <cygwin@...> | ||||||
|  |  | ||||||
| 	* libc/stdio/vfprintf.c: Fix typo in comments that breaks docs. | 	* libc/stdio/vfprintf.c: Fix typo in comments that breaks docs. | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ _DEFUN(_asniprintf_r, (ptr, buf, lenp, fmt), | |||||||
|       /* mark a zero-length reallocatable buffer */ |       /* mark a zero-length reallocatable buffer */ | ||||||
|       f._flags = __SWR | __SSTR | __SMBF; |       f._flags = __SWR | __SSTR | __SMBF; | ||||||
|       len = 0; |       len = 0; | ||||||
|  |       buf = NULL; | ||||||
|     } |     } | ||||||
|   f._bf._base = f._p = (unsigned char *) buf; |   f._bf._base = f._p = (unsigned char *) buf; | ||||||
|   /* For now, inherit the 32-bit signed limit of FILE._bf._size. |   /* For now, inherit the 32-bit signed limit of FILE._bf._size. | ||||||
| @@ -80,6 +81,7 @@ _DEFUN(asniprintf, (buf, lenp, fmt), | |||||||
|       /* mark a zero-length reallocatable buffer */ |       /* mark a zero-length reallocatable buffer */ | ||||||
|       f._flags = __SWR | __SSTR | __SMBF; |       f._flags = __SWR | __SSTR | __SMBF; | ||||||
|       len = 0; |       len = 0; | ||||||
|  |       buf = NULL; | ||||||
|     } |     } | ||||||
|   f._bf._base = f._p = (unsigned char *) buf; |   f._bf._base = f._p = (unsigned char *) buf; | ||||||
|   /* For now, inherit the 32-bit signed limit of FILE._bf._size. |   /* For now, inherit the 32-bit signed limit of FILE._bf._size. | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ _DEFUN(_asnprintf_r, (ptr, buf, lenp, fmt), | |||||||
|       /* mark a zero-length reallocatable buffer */ |       /* mark a zero-length reallocatable buffer */ | ||||||
|       f._flags = __SWR | __SSTR | __SMBF; |       f._flags = __SWR | __SSTR | __SMBF; | ||||||
|       len = 0; |       len = 0; | ||||||
|  |       buf = NULL; | ||||||
|     } |     } | ||||||
|   f._bf._base = f._p = (unsigned char *) buf; |   f._bf._base = f._p = (unsigned char *) buf; | ||||||
|   /* For now, inherit the 32-bit signed limit of FILE._bf._size. |   /* For now, inherit the 32-bit signed limit of FILE._bf._size. | ||||||
| @@ -80,6 +81,7 @@ _DEFUN(asnprintf, (buf, lenp, fmt), | |||||||
|       /* mark a zero-length reallocatable buffer */ |       /* mark a zero-length reallocatable buffer */ | ||||||
|       f._flags = __SWR | __SSTR | __SMBF; |       f._flags = __SWR | __SSTR | __SMBF; | ||||||
|       len = 0; |       len = 0; | ||||||
|  |       buf = NULL; | ||||||
|     } |     } | ||||||
|   f._bf._base = f._p = (unsigned char *) buf; |   f._bf._base = f._p = (unsigned char *) buf; | ||||||
|   /* For now, inherit the 32-bit signed limit of FILE._bf._size. |   /* For now, inherit the 32-bit signed limit of FILE._bf._size. | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ _DEFUN(_vasniprintf_r, (ptr, buf, lenp, fmt, ap), | |||||||
|       /* mark a zero-length reallocatable buffer */ |       /* mark a zero-length reallocatable buffer */ | ||||||
|       f._flags = __SWR | __SSTR | __SMBF; |       f._flags = __SWR | __SSTR | __SMBF; | ||||||
|       len = 0; |       len = 0; | ||||||
|  |       buf = NULL; | ||||||
|     } |     } | ||||||
|   f._bf._base = f._p = (unsigned char *) buf; |   f._bf._base = f._p = (unsigned char *) buf; | ||||||
|   /* For now, inherit the 32-bit signed limit of FILE._bf._size. |   /* For now, inherit the 32-bit signed limit of FILE._bf._size. | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ _DEFUN(_vasnprintf_r, (ptr, buf, lenp, fmt, ap), | |||||||
|       /* mark a zero-length reallocatable buffer */ |       /* mark a zero-length reallocatable buffer */ | ||||||
|       f._flags = __SWR | __SSTR | __SMBF; |       f._flags = __SWR | __SSTR | __SMBF; | ||||||
|       len = 0; |       len = 0; | ||||||
|  |       buf = NULL; | ||||||
|     } |     } | ||||||
|   f._bf._base = f._p = (unsigned char *) buf; |   f._bf._base = f._p = (unsigned char *) buf; | ||||||
|   /* For now, inherit the 32-bit signed limit of FILE._bf._size. |   /* For now, inherit the 32-bit signed limit of FILE._bf._size. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user