aboutsummaryrefslogtreecommitdiff
path: root/iconv/iconv_prog.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-12-29 15:57:15 +0000
committerUlrich Drepper <drepper@redhat.com>2001-12-29 15:57:15 +0000
commitd1dddedf7893fe70ed5d429485c8bcd0ab43f285 (patch)
tree99420c13234130854769150b8d81f5fe1d2528e3 /iconv/iconv_prog.c
parent9403ec5d23e7dc209361b3dbae2fdc184e1684aa (diff)
downloadglibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.gz
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.tar.bz2
glibc-d1dddedf7893fe70ed5d429485c8bcd0ab43f285.zip
Realloc error handling memory leak fix.
Diffstat (limited to 'iconv/iconv_prog.c')
-rw-r--r--iconv/iconv_prog.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
index 07296f07f0..94743b0d5d 100644
--- a/iconv/iconv_prog.c
+++ b/iconv/iconv_prog.c
@@ -516,12 +516,17 @@ process_fd (iconv_t cd, int fd, FILE *output)
while (1)
{
ssize_t n;
+ char *new_inbuf;
/* Increase the buffer. */
+ new_inbuf = (char *) realloc (inbuf, maxlen + 32768);
+ if (new_inbuf == NULL)
+ {
+ error (0, errno, _("unable to allocate buffer for input"));
+ return -1;
+ }
+ inbuf = new_inbuf;
maxlen += 32768;
- inbuf = realloc (inbuf, maxlen);
- if (inbuf == NULL)
- error (0, errno, _("unable to allocate buffer for input"));
inptr = inbuf + actlen;
do