From 5b36fbe08817c36a80f42d7a61b37e3821e67df9 Mon Sep 17 00:00:00 2001 From: "ivan.penkov@gmail.com" Date: Thu, 25 Apr 2013 21:32:55 +0000 Subject: Fixing a clang warning. This is a followup change from https://breakpad.appspot.com/569002/ This prevents push_back from ever calling Realloc() with 0 (which could happen if wasteful_vector was constructed with size_hint set to 0, causing allocated_ to be 0. Review URL: https://breakpad.appspot.com/576002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1166 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/memory.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/memory.h b/src/common/memory.h index b191449b..1fda60f9 100644 --- a/src/common/memory.h +++ b/src/common/memory.h @@ -35,6 +35,8 @@ #include #include +#include + #ifdef __APPLE__ #define sys_mmap mmap #define sys_mmap2 mmap @@ -159,7 +161,7 @@ class wasteful_vector { void push_back(const T& new_element) { if (used_ == allocated_) - Realloc(allocated_ * 2); + Realloc(std::max(allocated_ * 2, 1u)); a_[used_++] = new_element; } -- cgit v1.2.1