diff options
| author | Tim J. Robbins <tjr@FreeBSD.org> | 2002-08-04 02:52:11 +0000 |
|---|---|---|
| committer | Tim J. Robbins <tjr@FreeBSD.org> | 2002-08-04 02:52:11 +0000 |
| commit | d4ba1c2249c6f5d4c928966e5f1736371fe9e197 (patch) | |
| tree | f9d58ad8367157825abf648b2dd1c2a6cad69e74 /lib/libc | |
| parent | 9897b203568e7b490904beecf72ff191bafeb2a0 (diff) | |
Notes
Diffstat (limited to 'lib/libc')
| -rw-r--r-- | lib/libc/stdlib/calloc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/libc/stdlib/calloc.c b/lib/libc/stdlib/calloc.c index ced92732a722..863e546f5784 100644 --- a/lib/libc/stdlib/calloc.c +++ b/lib/libc/stdlib/calloc.c @@ -37,6 +37,8 @@ static char sccsid[] = "@(#)calloc.c 8.1 (Berkeley) 6/4/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <errno.h> +#include <limits.h> #include <stdlib.h> #include <string.h> @@ -47,6 +49,11 @@ calloc(num, size) { void *p; + if (size != 0 && SIZE_MAX / size < num) { + errno = ENOMEM; + return (NULL); + } + size *= num; if ( (p = malloc(size)) ) bzero(p, size); |
