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 | 194878fbac0a1598fdf7fc8d9045c183c195b6e7 (patch) | |
tree | 678bed6aead48c8a06aaa89113e1feb44a2cb65a /runtime | |
parent | e47ba74b07b2a6015239bcbabba09750580aeced (diff) | |
download | external_llvm-194878fbac0a1598fdf7fc8d9045c183c195b6e7.zip external_llvm-194878fbac0a1598fdf7fc8d9045c183c195b6e7.tar.gz external_llvm-194878fbac0a1598fdf7fc8d9045c183c195b6e7.tar.bz2 |
Don't call memset if malloc returns a null pointer
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16797 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/GCCLibraries/libc/memory.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/runtime/GCCLibraries/libc/memory.c b/runtime/GCCLibraries/libc/memory.c index 64aef89..ebca404 100644 --- a/runtime/GCCLibraries/libc/memory.c +++ b/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; } |