diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2006-09-30 17:12:06 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2006-09-30 17:12:06 +0000 |
commit | 4fd88b23ccaa1a5d89466bc4c12649f17b5ff92b (patch) | |
tree | 1a5849ccb6c865c4caf619ccd8598d5ab2b54c66 | |
parent | 3ae8d6700280297b485a897db86f710c1ca58251 (diff) | |
download | php-git-4fd88b23ccaa1a5d89466bc4c12649f17b5ff92b.tar.gz |
Added safety checks against integer overflow.
-rw-r--r-- | Zend/zend_alloc.c | 5 |
1 files 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; } |