diff options
author | Bruno Haible <bruno@clisp.org> | 2009-04-26 12:24:08 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2009-04-26 12:24:08 +0200 |
commit | a5bd4a560247e63db562041f9d136ba83a8b95fb (patch) | |
tree | e78a56a7b3baa334b9976092c5b07f2cb6647e95 /lib/uniconv | |
parent | a9c53428e9ec1fd0f085fd197027abc727c3a59f (diff) | |
download | gnulib-a5bd4a560247e63db562041f9d136ba83a8b95fb.tar.gz |
Avoid test failures on AIX and OSF/1.
Diffstat (limited to 'lib/uniconv')
-rw-r--r-- | lib/uniconv/u-conv-to-enc.h | 15 | ||||
-rw-r--r-- | lib/uniconv/u8-conv-from-enc.c | 4 | ||||
-rw-r--r-- | lib/uniconv/u8-conv-to-enc.c | 4 |
3 files changed, 11 insertions, 12 deletions
diff --git a/lib/uniconv/u-conv-to-enc.h b/lib/uniconv/u-conv-to-enc.h index 68ff81484b..144ea40171 100644 --- a/lib/uniconv/u-conv-to-enc.h +++ b/lib/uniconv/u-conv-to-enc.h @@ -1,5 +1,5 @@ /* Conversion from UTF-16/UTF-32 to legacy encodings. - Copyright (C) 2002, 2006-2008 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -25,7 +25,7 @@ FUNC (const char *tocode, size_t *scaled_offsets; int retval; - if (offsets != NULL) + if (offsets != NULL && srclen > 0) { scaled_offsets = (size_t *) malloc (srclen * sizeof (UNIT) * sizeof (size_t)); @@ -70,7 +70,7 @@ FUNC (const char *tocode, return -1; utf8_srclen = tmpbufsize; - if (offsets != NULL) + if (offsets != NULL && utf8_srclen > 0) { scaled_offsets = (size_t *) malloc (utf8_srclen * sizeof (size_t)); if (scaled_offsets == NULL) @@ -88,12 +88,11 @@ FUNC (const char *tocode, scaled_offsets, resultp, lengthp); if (retval < 0) { + int saved_errno = errno; + free (scaled_offsets); if (utf8_src != tmpbuf) - { - int saved_errno = errno; - free (utf8_src); - errno = saved_errno; - } + free (utf8_src); + errno = saved_errno; return -1; } if (offsets != NULL) diff --git a/lib/uniconv/u8-conv-from-enc.c b/lib/uniconv/u8-conv-from-enc.c index bcd0cd081f..09eba1e519 100644 --- a/lib/uniconv/u8-conv-from-enc.c +++ b/lib/uniconv/u8-conv-from-enc.c @@ -1,5 +1,5 @@ /* Conversion to UTF-8 from legacy encodings. - Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -65,7 +65,7 @@ u8_conv_from_encoding (const char *fromcode, } /* Memory allocation. */ - if (*resultp != NULL && *lengthp >= srclen) + if ((*resultp != NULL && *lengthp >= srclen) || srclen == 0) result = *resultp; else { diff --git a/lib/uniconv/u8-conv-to-enc.c b/lib/uniconv/u8-conv-to-enc.c index bc2cc09c93..85404d4be9 100644 --- a/lib/uniconv/u8-conv-to-enc.c +++ b/lib/uniconv/u8-conv-to-enc.c @@ -1,5 +1,5 @@ /* Conversion from UTF-8 to legacy encodings. - Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. + Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published @@ -50,7 +50,7 @@ u8_conv_to_encoding (const char *tocode, #endif /* Memory allocation. */ - if (*resultp != NULL && *lengthp >= srclen) + if ((*resultp != NULL && *lengthp >= srclen) || srclen == 0) result = *resultp; else { |