aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-04-25 21:32:55 +0000
committerivan.penkov@gmail.com <ivan.penkov@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-04-25 21:32:55 +0000
commit5b36fbe08817c36a80f42d7a61b37e3821e67df9 (patch)
treeebd3e2289cefdb8316d00bb846cac8efefd92e71 /src
parentAdd MD_OS_PS3 to breakpad and exception types. (diff)
downloadbreakpad-5b36fbe08817c36a80f42d7a61b37e3821e67df9.tar.xz
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
Diffstat (limited to 'src')
-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 b191449b..1fda60f9 100644
--- a/src/common/memory.h
+++ b/src/common/memory.h
@@ -35,6 +35,8 @@
#include <unistd.h>
#include <sys/mman.h>
+#include <algorithm>
+
#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;
}