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

Unified Diff: chrome/browser/extensions/api/usb/usb_device_resource.cc

Issue 10826273: Allocate a one-byte IOBuffer for transfers that are zero-length. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/browser/extensions/api/usb/usb_device_resource.cc
diff --git a/chrome/browser/extensions/api/usb/usb_device_resource.cc b/chrome/browser/extensions/api/usb/usb_device_resource.cc
index da8efdf499c5239c2131ab0b2e8ea709b6bd1ec1..bb0aaa68d88f76173f252997da6ca1d4872d4bd4 100644
--- a/chrome/browser/extensions/api/usb/usb_device_resource.cc
+++ b/chrome/browser/extensions/api/usb/usb_device_resource.cc
@@ -115,13 +115,13 @@ static scoped_refptr<net::IOBuffer> CreateBufferForTransfer(const T& input) {
return NULL;
}
- scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(size);
+ scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(std::max(
+ static_cast<size_t>(1), size));
if (!input.data.get()) {
bryeung 2012/08/13 15:22:28 nit: this if and the one above should be brace-les
return buffer;
}
memcpy(buffer->data(), input.data->data(), size);
-
return buffer;
}
« 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