Mercurial > hg > octave-lyh > gnulib-hg
changeset 9553:d6b837735949
* lib/memmem.c (knuth_morris_pratt): Check for size_t overflow
when multiplying M by sizeof (size_t).
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Sat, 29 Dec 2007 01:17:08 -0800 |
parents | 6632990b0812 |
children | 3ab8c751bb32 |
files | ChangeLog lib/memmem.c |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-12-29 Paul Eggert <eggert@cs.ucla.edu> + + * lib/memmem.c (knuth_morris_pratt): Check for size_t overflow + when multiplying M by sizeof (size_t). + 2007-12-10 Martin Lambers <marlam@marlam.de> Override getpagesize on mingw.
--- a/lib/memmem.c +++ b/lib/memmem.c @@ -39,7 +39,10 @@ const char **resultp) { /* Allocate the table. */ - size_t *table = (size_t *) malloca (m * sizeof (size_t)); + size_t *table; + if ((size_t) -1 / sizeof (size_t) < m) + return false; + table = (size_t *) malloca (m * sizeof (size_t)); if (table == NULL) return false; /* Fill the table.