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

Unified Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 274673002: Pepper: Fix crash on allocation failure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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: components/nacl/renderer/ppb_nacl_private_impl.cc
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 3361f61783c86f485bdf6ae9bcb5224e1ec5a44a..f3c87f27777042bda54f97baddc6f40b0d7de3b7 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -1136,16 +1136,38 @@ PP_Bool GetPNaClResourceInfo(PP_Instance instance,
return PP_FALSE;
}
- const int kBufferSize = 1 << 20;
- scoped_ptr<char[]> buffer(new char[kBufferSize]);
- if (base::ReadPlatformFile(file, 0, buffer.get(), kBufferSize) < 0) {
+ base::PlatformFileInfo file_info;
+ if (!GetPlatformFileInfo(file, &file_info)) {
load_manager->ReportLoadError(
PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
- std::string("PnaclResources::ReadResourceInfo reading failed for: ") +
+ std::string("GetPNaClResourceInfo, GetFileInfo failed for: ") +
filename);
return PP_FALSE;
}
+ if (file_info.size > 1 << 20) {
bbudge 2014/05/08 00:15:59 The old behavior seems bad since it would only do
+ load_manager->ReportLoadError(
+ PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
+ std::string("GetPNaClResourceInfo, file too large: ") + filename);
+ return PP_FALSE;
+ }
+
+ scoped_ptr<char[]> buffer(new char[file_info.size]);
+ if (buffer.get() == NULL) {
+ load_manager->ReportLoadError(
+ PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
+ std::string("GetPNaClResourceInfo, couldn't allocate for: ") +
+ filename);
+ return PP_FALSE;
+ }
+
+ if (base::ReadPlatformFile(file, 0, buffer.get(), file_info.size) < 0) {
+ load_manager->ReportLoadError(
+ PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
+ std::string("GetPNaClResourceInfo, reading failed for: ") + filename);
+ return PP_FALSE;
+ }
+
// Expect the JSON file to contain a top-level object (dictionary).
Json::Reader json_reader;
Json::Value json_data;
« 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