projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From Derek Price:
[gnulib.git]
/
lib
/
linebreak.c
diff --git
a/lib/linebreak.c
b/lib/linebreak.c
index
8623eb0
..
f38f464
100644
(file)
--- a/
lib/linebreak.c
+++ b/
lib/linebreak.c
@@
-26,6
+26,7
@@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <stdlib.h>
#include <string.h>
#include "c-ctype.h"
#include <stdlib.h>
#include <string.h>
#include "c-ctype.h"
+#include "xsize.h"
#include "utf8-ucs4.h"
#include "utf8-ucs4.h"
@@
-1023,7
+1024,7
@@
u8_width_linebreaks (const unsigned char *s, size_t n,
/* No line break for the moment, may be turned into
UC_BREAK_POSSIBLE later, via last_p. */
}
/* 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);
*p = UC_BREAK_PROHIBITED;
w = uc_width (uc, encoding);
@@
-1107,7
+1108,7
@@
u16_width_linebreaks (const unsigned short *s, size_t n,
/* No line break for the moment, may be turned into
UC_BREAK_POSSIBLE later, via last_p. */
}
/* 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);
*p = UC_BREAK_PROHIBITED;
w = uc_width (uc, encoding);
@@
-1190,7
+1191,7
@@
u32_width_linebreaks (const unsigned int *s, size_t n,
/* No line break for the moment, may be turned into
UC_BREAK_POSSIBLE later, via last_p. */
}
/* 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);
*p = UC_BREAK_PROHIBITED;
w = uc_width (uc, encoding);
@@
-1519,7
+1520,9
@@
mbs_possible_linebreaks (const char *s, size_t n, const char *encoding,
{
/* Convert the string to UTF-8 and build a translation table
from offsets into s to offsets into the translated string. */
{
/* 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;
if (memory != NULL)
{
size_t *offtable = (size_t *) memory;
@@
-1612,7
+1615,11
@@
mbs_width_linebreaks (const char *s, size_t n,
{
/* Convert the string to UTF-8 and build a translation table
from offsets into s to offsets into the translated string. */
{
/* 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;
if (memory != NULL)
{
size_t *offtable = (size_t *) memory;