Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Unified Diff: net/base/io_buffer.cc

Issue 338049: Handle out of memory in GrowableIOBuffer more gracefully.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/io_buffer.cc
===================================================================
--- net/base/io_buffer.cc (revision 30229)
+++ net/base/io_buffer.cc (working copy)
@@ -19,15 +19,21 @@
data_ = base_->data() + used_;
}
-void GrowableIOBuffer::set_capacity(int capacity) {
+bool GrowableIOBuffer::SetCapacity(int capacity) {
DCHECK_GE(capacity, 0);
wtc 2009/11/09 22:37:23 Let's change this DCHECK to a CHECK.
- real_data_.reset(static_cast<char*>(realloc(real_data_.release(), capacity)));
+ char* cur_buf = real_data_.release();
+ real_data_.reset(static_cast<char*>(realloc(cur_buf, capacity)));
+ if (real_data_.get() == NULL && capacity != 0) {
+ real_data_.reset(cur_buf);
+ return false;
+ }
capacity_ = capacity;
CHECK(real_data_.get() != NULL || capacity == 0);
wtc 2009/10/27 22:42:10 You can remove this CHECK now because its expressi
if (offset_ > capacity)
set_offset(capacity);
else
set_offset(offset_); // The pointer may have changed.
+ return true;
}
void GrowableIOBuffer::set_offset(int offset) {

Powered by Google App Engine
This is Rietveld 408576698