diff options
author | Chris Lattner <sabre@nondot.org> | 2004-10-06 23:08:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-10-06 23:08:03 +0000 |
commit | 76319a83bd09ee8aabcf7bb639984b990514eeaf (patch) | |
tree | 9d7cb549b8b34d769e9b7790c62f661fbd9e0f94 /llvm/runtime/GCCLibraries | |
parent | 1f849a08a353a836c85382185c0d202c5154b9e8 (diff) | |
download | bcm5719-llvm-76319a83bd09ee8aabcf7bb639984b990514eeaf.tar.gz bcm5719-llvm-76319a83bd09ee8aabcf7bb639984b990514eeaf.zip |
Don't call memset if malloc returns a null pointer
llvm-svn: 16797
Diffstat (limited to 'llvm/runtime/GCCLibraries')
-rw-r--r-- | llvm/runtime/GCCLibraries/libc/memory.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/runtime/GCCLibraries/libc/memory.c b/llvm/runtime/GCCLibraries/libc/memory.c index 64aef89094a..ebca404d488 100644 --- a/llvm/runtime/GCCLibraries/libc/memory.c +++ b/llvm/runtime/GCCLibraries/libc/memory.c @@ -28,5 +28,6 @@ void *calloc(size_t nelem, size_t elsize) __ATTRIBUTE_WEAK__; void *calloc(size_t nelem, size_t elsize) { void *Result = malloc(nelem*elsize); - return memset(Result, 0, nelem*elsize); + if (Result) memset(Result, 0, nelem*elsize); + return Result; } |