mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
[BZ #2072]
* stdio-common/printf_fp.c: Fix potential memory leaks for malloc'ed wbuffer isn't freed in error conditions.
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
2006-04-25 Ulrich Drepper <drepper@redhat.com>
|
2006-04-25 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
[BZ #2072]
|
||||||
|
* stdio-common/printf_fp.c: Fix potential memory leaks for
|
||||||
|
malloc'ed wbuffer isn't freed in error conditions.
|
||||||
|
|
||||||
[BZ #2569]
|
[BZ #2569]
|
||||||
* iconv/gconv_db.c (__gconv_release_step): Fix condition of assert
|
* iconv/gconv_db.c (__gconv_release_step): Fix condition of assert
|
||||||
call.
|
call.
|
||||||
|
@@ -72,7 +72,11 @@
|
|||||||
{ \
|
{ \
|
||||||
register const int outc = (ch); \
|
register const int outc = (ch); \
|
||||||
if (putc (outc, fp) == EOF) \
|
if (putc (outc, fp) == EOF) \
|
||||||
return -1; \
|
{ \
|
||||||
|
if (buffer_malloced) \
|
||||||
|
free (wbuffer); \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
++done; \
|
++done; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -83,7 +87,11 @@
|
|||||||
if (len > 20) \
|
if (len > 20) \
|
||||||
{ \
|
{ \
|
||||||
if (PUT (fp, wide ? (const char *) wptr : ptr, outlen) != outlen) \
|
if (PUT (fp, wide ? (const char *) wptr : ptr, outlen) != outlen) \
|
||||||
return -1; \
|
{ \
|
||||||
|
if (buffer_malloced) \
|
||||||
|
free (wbuffer); \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
ptr += outlen; \
|
ptr += outlen; \
|
||||||
done += outlen; \
|
done += outlen; \
|
||||||
} \
|
} \
|
||||||
@@ -102,7 +110,11 @@
|
|||||||
do \
|
do \
|
||||||
{ \
|
{ \
|
||||||
if (PAD (fp, ch, len) != len) \
|
if (PAD (fp, ch, len) != len) \
|
||||||
return -1; \
|
{ \
|
||||||
|
if (buffer_malloced) \
|
||||||
|
free (wbuffer); \
|
||||||
|
return -1; \
|
||||||
|
} \
|
||||||
done += len; \
|
done += len; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
@@ -200,6 +212,11 @@ ___printf_fp (FILE *fp,
|
|||||||
/* Nonzero if this is output on a wide character stream. */
|
/* Nonzero if this is output on a wide character stream. */
|
||||||
int wide = info->wide;
|
int wide = info->wide;
|
||||||
|
|
||||||
|
/* Buffer in which we produce the output. */
|
||||||
|
wchar_t *wbuffer = NULL;
|
||||||
|
/* Flag whether wbuffer is malloc'ed or not. */
|
||||||
|
int buffer_malloced = 0;
|
||||||
|
|
||||||
auto wchar_t hack_digit (void);
|
auto wchar_t hack_digit (void);
|
||||||
|
|
||||||
wchar_t hack_digit (void)
|
wchar_t hack_digit (void)
|
||||||
@@ -790,8 +807,7 @@ ___printf_fp (FILE *fp,
|
|||||||
|
|
||||||
{
|
{
|
||||||
int width = info->width;
|
int width = info->width;
|
||||||
wchar_t *wbuffer, *wstartp, *wcp;
|
wchar_t *wstartp, *wcp;
|
||||||
int buffer_malloced;
|
|
||||||
int chars_needed;
|
int chars_needed;
|
||||||
int expscale;
|
int expscale;
|
||||||
int intdig_max, intdig_no = 0;
|
int intdig_max, intdig_no = 0;
|
||||||
@@ -1109,8 +1125,12 @@ ___printf_fp (FILE *fp,
|
|||||||
buffer = (char *) malloc (2 + chars_needed + decimal_len
|
buffer = (char *) malloc (2 + chars_needed + decimal_len
|
||||||
+ ngroups * thousands_sep_len);
|
+ ngroups * thousands_sep_len);
|
||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
/* Signal an error to the caller. */
|
{
|
||||||
return -1;
|
/* Signal an error to the caller. */
|
||||||
|
if (buffer_malloced)
|
||||||
|
free (wbuffer);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
buffer = (char *) alloca (2 + chars_needed + decimal_len
|
buffer = (char *) alloca (2 + chars_needed + decimal_len
|
||||||
|
Reference in New Issue
Block a user