diff options
author | miod <> | 2002-07-31 09:25:20 +0000 |
---|---|---|
committer | miod <> | 2002-07-31 09:25:20 +0000 |
commit | c9d85f8d35714ca2c84032992daa9f54a2811531 (patch) | |
tree | 7e9a4ab434c9a888e16e1230e37c3f82cd1ef60d /src/lib/libc/stdlib | |
parent | 61657c023155257c3c485c2bdd290c94ce737683 (diff) | |
download | openbsd-c9d85f8d35714ca2c84032992daa9f54a2811531.tar.gz openbsd-c9d85f8d35714ca2c84032992daa9f54a2811531.tar.bz2 openbsd-c9d85f8d35714ca2c84032992daa9f54a2811531.zip |
MFC (deraadt):
permit calloc(0, N) and calloc(N, 0) -- malloc(0) does the right thing
Diffstat (limited to 'src/lib/libc/stdlib')
-rw-r--r-- | src/lib/libc/stdlib/calloc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libc/stdlib/calloc.c b/src/lib/libc/stdlib/calloc.c index a9e49e39ad..b944df6fa2 100644 --- a/src/lib/libc/stdlib/calloc.c +++ b/src/lib/libc/stdlib/calloc.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char *rcsid = "$OpenBSD: calloc.c,v 1.5.8.1 2002/07/30 07:31:20 miod Exp $"; | 35 | static char *rcsid = "$OpenBSD: calloc.c,v 1.5.8.2 2002/07/31 09:25:20 miod Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
@@ -47,7 +47,7 @@ calloc(num, size) | |||
47 | { | 47 | { |
48 | register void *p; | 48 | register void *p; |
49 | 49 | ||
50 | if (SIZE_T_MAX / num < size) { | 50 | if (num && size && SIZE_T_MAX / num < size) { |
51 | errno = ENOMEM; | 51 | errno = ENOMEM; |
52 | return NULL; | 52 | return NULL; |
53 | } | 53 | } |