summaryrefslogtreecommitdiff
path: root/lib/striconveh.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-09-04 15:16:35 +0200
committerLudovic Courtès <ludo@gnu.org>2010-09-04 15:16:35 +0200
commit9157d901024558ca2cb2a59d21f26b7f897714cd (patch)
treef6174b78e2213e49df81a47417f83ca6c1c8807b /lib/striconveh.c
parentfb0b64c12a40529a03c22481570a11457076b7f9 (diff)
Use Gnulib's `stat-time' module; update Gnulib.
This updates Gnulib files to v0.0-4207-gc82b481. * m4/gnulib-cache.m4: Add `stat-time'.
Diffstat (limited to 'lib/striconveh.c')
-rw-r--r--lib/striconveh.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/striconveh.c b/lib/striconveh.c
index ae10f3c1c..8db6677a5 100644
--- a/lib/striconveh.c
+++ b/lib/striconveh.c
@@ -970,19 +970,23 @@ mem_cd_iconveh_internal (const char *src, size_t srclen,
if (result == tmpbuf)
{
size_t memsize = length + extra_alloc;
- char *memory;
- memory = (char *) malloc (memsize > 0 ? memsize : 1);
- if (memory != NULL)
- {
- memcpy (memory, tmpbuf, length);
- result = memory;
- }
+ if (*resultp != NULL && *lengthp >= memsize)
+ result = *resultp;
else
{
- errno = ENOMEM;
- return -1;
+ char *memory;
+
+ memory = (char *) malloc (memsize > 0 ? memsize : 1);
+ if (memory != NULL)
+ result = memory;
+ else
+ {
+ errno = ENOMEM;
+ return -1;
+ }
}
+ memcpy (result, tmpbuf, length);
}
else if (result != *resultp && length + extra_alloc < allocated)
{