From ae3947e1234a53eab752f7f81272cf3e00dc1a34 Mon Sep 17 00:00:00 2001 From: "ivan.penkov@gmail.com" Date: Wed, 24 Apr 2013 21:02:55 +0000 Subject: Fix Clang warning regarding null pointer argument. This warning was showing up in the Clang static analyzer in Xcode: "Null pointer argument in call to memory copy function" Fix provided by Ian Wilkinson. Review URL: https://breakpad.appspot.com/569002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1162 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/memory.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/common/memory.h b/src/common/memory.h index e90bd52c..b191449b 100644 --- a/src/common/memory.h +++ b/src/common/memory.h @@ -197,7 +197,9 @@ class wasteful_vector { void Realloc(unsigned new_size) { T *new_array = reinterpret_cast(allocator_->Alloc(sizeof(T) * new_size)); - memcpy(new_array, a_, used_ * sizeof(T)); + if (new_size > 0) { + memcpy(new_array, a_, used_ * sizeof(T)); + } a_ = new_array; allocated_ = new_size; } -- cgit v1.2.1