* [PATCH] One more calloc fix
@ 2002-08-07 3:21 Jakub Jelinek
2002-08-07 12:32 ` Roland McGrath
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2002-08-07 3:21 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
Hi!
calloc (131072, 0) ought to work like malloc (0), but it will crash
on 32-bit arches.
The check is in the unlikely executed chunk of code, so it shouldn't
slow things down.
2002-08-07 Jakub Jelinek <jakub@redhat.com>
* malloc/malloc.c (public_cALLOc): Check elem_size != 0 before
division.
--- libc/malloc/malloc.c.jj 2002-08-05 08:44:17.000000000 +0200
+++ libc/malloc/malloc.c 2002-08-07 12:37:58.000000000 +0200
@@ -3474,7 +3474,7 @@ public_cALLOc(size_t n, size_t elem_size
#define HALF_INTERNAL_SIZE_T \
(((INTERNAL_SIZE_T) 1) << (8 * sizeof (INTERNAL_SIZE_T) / 2))
if (__builtin_expect ((n | elem_size) >= HALF_INTERNAL_SIZE_T, 0)) {
- if (bytes / elem_size != n) {
+ if (elem_size != 0 && bytes / elem_size != n) {
MALLOC_FAILURE_ACTION;
return 0;
}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] One more calloc fix
2002-08-07 3:21 [PATCH] One more calloc fix Jakub Jelinek
@ 2002-08-07 12:32 ` Roland McGrath
0 siblings, 0 replies; 2+ messages in thread
From: Roland McGrath @ 2002-08-07 12:32 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Ulrich Drepper, Glibc hackers
Thanks, I put that in.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-08-07 19:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-07 3:21 [PATCH] One more calloc fix Jakub Jelinek
2002-08-07 12:32 ` Roland McGrath
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).