summaryrefslogtreecommitdiffstats
path: root/runtime/libprofile/CommonProfiling.c
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-08-15 19:34:23 +0000
committerdim <dim@FreeBSD.org>2012-08-15 19:34:23 +0000
commit721c201bd55ffb73cb2ba8d39e0570fa38c44e15 (patch)
treeeacfc83d988e4b9d11114387ae7dc41243f2a363 /runtime/libprofile/CommonProfiling.c
parent2b2816e083a455f7a656ae88b0fd059d1688bb36 (diff)
downloadFreeBSD-src-721c201bd55ffb73cb2ba8d39e0570fa38c44e15.zip
FreeBSD-src-721c201bd55ffb73cb2ba8d39e0570fa38c44e15.tar.gz
Vendor import of llvm trunk r161861:
http://llvm.org/svn/llvm-project/llvm/trunk@161861
Diffstat (limited to 'runtime/libprofile/CommonProfiling.c')
-rw-r--r--runtime/libprofile/CommonProfiling.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/runtime/libprofile/CommonProfiling.c b/runtime/libprofile/CommonProfiling.c
index d55f51c..acc17ce 100644
--- a/runtime/libprofile/CommonProfiling.c
+++ b/runtime/libprofile/CommonProfiling.c
@@ -65,6 +65,16 @@ int save_arguments(int argc, const char **argv) {
for (Length = 0, i = 0; i != (unsigned)argc; ++i)
Length += strlen(argv[i])+1;
+ /* Defensively check for a zero length, even though this is unlikely
+ * to happen in practice. This avoids calling malloc() below with a
+ * size of 0.
+ */
+ if (Length == 0) {
+ SavedArgs = 0;
+ SavedArgsLength = 0;
+ return argc;
+ }
+
SavedArgs = (char*)malloc(Length);
for (Length = 0, i = 0; i != (unsigned)argc; ++i) {
unsigned Len = strlen(argv[i]);
OpenPOWER on IntegriCloud