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

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: Review nits. 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..908f7fb16ed35016f78b09533933a6aaea86b381 100644
--- a/chrome/browser/extensions/api/usb/usb_device_resource.cc
+++ b/chrome/browser/extensions/api/usb/usb_device_resource.cc
@@ -111,17 +111,15 @@ static bool GetTransferSize(const T& input, size_t* output) {
template<class T>
static scoped_refptr<net::IOBuffer> CreateBufferForTransfer(const T& input) {
size_t size = 0;
- if (!GetTransferSize(input, &size)) {
+ if (!GetTransferSize(input, &size))
return NULL;
- }
- scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(size);
- if (!input.data.get()) {
+ scoped_refptr<net::IOBuffer> buffer = new net::IOBuffer(std::max(
asargent_no_longer_on_chrome 2012/08/13 17:37:50 can you include a brief comment here about why we
+ static_cast<size_t>(1), size));
+ if (!input.data.get())
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