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
This commit is contained in:
ivan.penkov@gmail.com 2013-04-24 21:02:55 +00:00
parent 77acc6adab
commit ae3947e123

View file

@ -197,7 +197,9 @@ class wasteful_vector {
void Realloc(unsigned new_size) {
T *new_array =
reinterpret_cast<T*>(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;
}