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

Unified Diff: chrome/test/chromedriver/chrome/zip_internal.cc

Issue 149543004: Avoid deferencing a pointer before checking it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reupload Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/chrome/zip_internal.cc
diff --git a/chrome/test/chromedriver/chrome/zip_internal.cc b/chrome/test/chromedriver/chrome/zip_internal.cc
index b8f6349b5ee58936a9b2c61f65d81ead0f97ac42..18b1cce458b3199548855b95b007717e9cc50cf7 100644
--- a/chrome/test/chromedriver/chrome/zip_internal.cc
+++ b/chrome/test/chromedriver/chrome/zip_internal.cc
@@ -161,12 +161,14 @@ void* OpenZipBuffer(void* opaque, const char* /*filename*/, int mode) {
}
// Reads compressed data from the specified stream. This function copies data
-// refered by the opaque parameter and returns the size actually copied.
+// referred by the opaque parameter and returns the size actually copied.
uLong ReadZipBuffer(void* opaque, void* /*stream*/, void* buf, uLong size) {
ZipBuffer* buffer = static_cast<ZipBuffer*>(opaque);
+ if (!buffer)
+ return 0;
DCHECK_LE(buffer->offset, buffer->length);
size_t remaining_bytes = buffer->length - buffer->offset;
- if (!buffer || !buffer->data || !remaining_bytes)
+ if (!buffer->data || !remaining_bytes)
return 0;
size = std::min(size, static_cast<uLong>(remaining_bytes));
memcpy(buf, &buffer->data[buffer->offset], size);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698