From 4fd88b23ccaa1a5d89466bc4c12649f17b5ff92b Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sat, 30 Sep 2006 17:12:06 +0000 Subject: [PATCH] Added safety checks against integer overflow. --- Zend/zend_alloc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index c132175737..a51e963b4a 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -1730,13 +1730,12 @@ ZEND_API void *_safe_malloc(size_t nmemb, size_t size, size_t offset) ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) { void *p; - int final_size = size*nmemb; - p = _emalloc(final_size ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); + p = _safe_emalloc(nmemb, size, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); if (!p) { return (void *) p; } - memset(p, 0, final_size); + memset(p, 0, size * nmemb); return p; } -- 2.50.1