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

Unified Diff: courgette/third_party/bsdiff_apply.cc

Issue 6716006: Identifying call sites that need to handle out of memory situations in Courgette. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 9 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: courgette/third_party/bsdiff_apply.cc
===================================================================
--- courgette/third_party/bsdiff_apply.cc (revision 78901)
+++ courgette/third_party/bsdiff_apply.cc (working copy)
@@ -77,7 +77,8 @@
const uint8* old_position = old_start;
- new_stream->Reserve(header->dlen);
+ if (header->dlen && !new_stream->Reserve(header->dlen))
+ return MEM_ERROR;
uint32 pending_diff_zeros = 0;
if (!diff_skips->ReadVarint32(&pending_diff_zeros))
@@ -114,7 +115,8 @@
return UNEXPECTED_ERROR;
}
uint8 byte = old_position[i] + diff_byte;
- new_stream->Write(&byte, 1);
+ if (!new_stream->Write(&byte, 1))
+ return MEM_ERROR;
}
old_position += copy_count;
@@ -122,7 +124,9 @@
if (extra_count > static_cast<size_t>(extra_end - extra_position))
return UNEXPECTED_ERROR;
- new_stream->Write(extra_position, extra_count);
+ if (!new_stream->Write(extra_position, extra_count))
+ return MEM_ERROR;
+
extra_position += extra_count;
// "seek" forwards (or backwards) in oldfile.

Powered by Google App Engine
This is Rietveld 408576698