aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/memory.h4
1 files changed, 3 insertions, 1 deletions
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<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;
}