Commit 7ba4ac11 authored by binji@chromium.org's avatar binji@chromium.org

[NaCl SDK] nacl_io: HTTP mount bugfix, w/ packaged app and content cache.

This fixes a bug when reading from a HTTP mount, if the Content-Length header
is not available.

It occurs because the code was caching a pointer to a std::vector's buffer,
after it had resized it.

BUG=none
R=noelallen@chromium.org

Review URL: https://codereview.chromium.org/13831005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194646 0039d316-1c4b-4281-b951-d872f2087c98
parent 6558fd4f
......@@ -418,10 +418,10 @@ int MountNodeHttp::DownloadToCache() {
// We don't know how big the file is. Read in chunks.
cached_data_.resize(MAX_READ_BUFFER_SIZE);
char* buf = cached_data_.data();
size_t total_bytes_read = 0;
size_t bytes_to_read = MAX_READ_BUFFER_SIZE;
while (true) {
char* buf = cached_data_.data() + total_bytes_read;
int bytes_read = DownloadToBuffer(loader, buf, bytes_to_read);
if (bytes_read < 0)
return -1;
......@@ -434,7 +434,6 @@ int MountNodeHttp::DownloadToCache() {
return total_bytes_read;
}
buf += bytes_read;
cached_data_.resize(total_bytes_read + bytes_to_read);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment