aboutsummaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-06 23:08:03 +0000
committerChris Lattner <sabre@nondot.org>2004-10-06 23:08:03 +0000
commit194878fbac0a1598fdf7fc8d9045c183c195b6e7 (patch)
tree678bed6aead48c8a06aaa89113e1feb44a2cb65a /runtime
parente47ba74b07b2a6015239bcbabba09750580aeced (diff)
downloadexternal_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.c3
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;
}