aboutsummaryrefslogtreecommitdiff
path: root/iconv
diff options
context:
space:
mode:
Diffstat (limited to 'iconv')
-rw-r--r--iconv/iconv_charmap.c13
-rw-r--r--iconv/iconv_prog.c11
2 files changed, 17 insertions, 7 deletions
diff --git a/iconv/iconv_charmap.c b/iconv/iconv_charmap.c
index 141c8eca2d..03a8f5fa23 100644
--- a/iconv/iconv_charmap.c
+++ b/iconv/iconv_charmap.c
@@ -483,7 +483,7 @@ incomplete character or shift sequence at end of buffer"));
static int
process_fd (struct convtable *tbl, int fd, FILE *output)
{
- /* we have a problem with reading from a desriptor since we must not
+ /* We have a problem with reading from a descriptor since we must not
provide the iconv() function an incomplete character or shift
sequence at the end of the buffer. Since we have to deal with
arbitrary encodings we must read the whole text in a buffer and
@@ -516,12 +516,17 @@ process_fd (struct convtable *tbl, 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
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