# HG changeset patch # User Bruno Haible # Date 1067947595 0 # Node ID 5d25a00a850276b9111e14e8791a8bd868312c8c # Parent 7f909e1de364c442ba3090185b30af1c3999bc16 Use xsize. diff --git a/lib/linebreak.c b/lib/linebreak.c --- a/lib/linebreak.c +++ b/lib/linebreak.c @@ -26,6 +26,7 @@ #include #include #include "c-ctype.h" +#include "xsize.h" #include "utf8-ucs4.h" @@ -1519,7 +1520,9 @@ { /* 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; @@ -1612,7 +1615,11 @@ { /* 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; diff --git a/modules/linebreak b/modules/linebreak --- a/modules/linebreak +++ b/modules/linebreak @@ -13,6 +13,7 @@ iconv utf8-ucs4 utf16-ucs4 +xsize configure.ac: gl_LINEBREAK