You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#include <stdlib.h>
#include <string.h>
#include "c-ctype.h"
+#include "xsize.h"
#include "utf8-ucs4.h"
/* No line break for the moment, may be turned into
UC_BREAK_POSSIBLE later, via last_p. */
}
-
+
*p = UC_BREAK_PROHIBITED;
w = uc_width (uc, encoding);
/* No line break for the moment, may be turned into
UC_BREAK_POSSIBLE later, via last_p. */
}
-
+
*p = UC_BREAK_PROHIBITED;
w = uc_width (uc, encoding);
/* No line break for the moment, may be turned into
UC_BREAK_POSSIBLE later, via last_p. */
}
-
+
*p = UC_BREAK_PROHIBITED;
w = uc_width (uc, encoding);
char *outptr = tmpbuf;
size_t outsize = TMPBUFSIZE;
size_t res = iconv (cd, (ICONV_CONST char **) &inptr, &insize, &outptr, &outsize);
- if (res == (size_t)(-1))
+ if (res == (size_t)(-1) && errno != E2BIG)
return (size_t)(-1);
count += outptr - tmpbuf;
}
- /* Avoid glibc-2.1 bug and Solaris 2.7-2.9 bug. */
+ /* Avoid glibc-2.1 bug and Solaris 7 through 9 bug. */
#if defined _LIBICONV_VERSION \
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
{
if (res == (size_t)(-1))
abort ();
}
- /* Avoid glibc-2.1 bug and Solaris 2.7 bug. */
+ /* Avoid glibc-2.1 bug and Solaris 7 bug. */
#if defined _LIBICONV_VERSION \
|| !((__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) || defined __sun)
if (iconv (cd, NULL, NULL, &outptr, &outsize) == (size_t)(-1))
to_utf8 = (iconv_t)(-1);
else
# endif
- /* Avoid Solaris 2.9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK,
+ /* Avoid Solaris 9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK,
GB18030. */
# if defined __sun && !defined _LIBICONV_VERSION
if ( STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
{
/* Convert the string to UTF-8 and build a translation table
from offsets into s to offsets into the translated string. */
- char *memory = malloc (n * sizeof (size_t) + m + m);
+ size_t memory_size = xsum3 (xtimes (n, sizeof (size_t)), m, m);
+ char *memory =
+ (size_in_bounds_p (memory_size) ? malloc (memory_size) : NULL);
if (memory != NULL)
{
size_t *offtable = (size_t *) memory;
to_utf8 = (iconv_t)(-1);
else
# endif
- /* Avoid Solaris 2.9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK,
+ /* Avoid Solaris 9 bug with GB2312, EUC-TW, BIG5, BIG5-HKSCS, GBK,
GB18030. */
# if defined __sun && !defined _LIBICONV_VERSION
if ( STREQ (encoding, "GB2312", 'G', 'B', '2', '3', '1', '2', 0, 0, 0)
{
/* Convert the string to UTF-8 and build a translation table
from offsets into s to offsets into the translated string. */
- char *memory = malloc (n * sizeof (size_t) + m + m + (o != NULL ? m : 0));
+ size_t memory_size =
+ xsum4 (xtimes (n, sizeof (size_t)), m, m,
+ (o != NULL ? m : 0));
+ char *memory =
+ (size_in_bounds_p (memory_size) ? malloc (memory_size) : NULL);
if (memory != NULL)
{
size_t *offtable = (size_t *) memory;