Skip to content

Commit

Permalink
Do not free the buffer owned by the kernel_data vector (flutter#4753)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Mar 7, 2018
1 parent 7f7634f commit 07e64fd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions runtime/dart_init.cc
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,10 @@ Dart_Isolate IsolateCreateCallback(const char* script_uri,

if (!kernel_data.empty()) {
// We are running kernel code.
uint8_t* kernel_buf = static_cast<uint8_t*>(malloc(kernel_data.size()));
memcpy(kernel_buf, kernel_data.data(), kernel_data.size());
FXL_CHECK(!LogIfError(Dart_LoadKernel(Dart_ReadKernelBinary(
kernel_data.data(), kernel_data.size(), ReleaseFetchedBytes))));
kernel_buf, kernel_data.size(), ReleaseFetchedBytes))));
} else if (!snapshot_data.empty()) {
// We are running from a script snapshot.
FXL_CHECK(!LogIfError(Dart_LoadScriptFromSnapshot(snapshot_data.data(),
Expand Down Expand Up @@ -636,8 +638,10 @@ void InitDartVM(const uint8_t* vm_snapshot_data,
directory_asset_bundle->GetAsBuffer(kPlatformKernelAssetKey,
&platform_data);
if (!platform_data.empty()) {
kernel_platform = Dart_ReadKernelBinary(
platform_data.data(), platform_data.size(), ReleaseFetchedBytes);
uint8_t* kernel_buf = static_cast<uint8_t*>(malloc(platform_data.size()));
memcpy(kernel_buf, platform_data.data(), platform_data.size());
kernel_platform = Dart_ReadKernelBinary(kernel_buf, platform_data.size(),
ReleaseFetchedBytes);
FXL_DCHECK(kernel_platform != nullptr);
}
}
Expand Down

0 comments on commit 07e64fd

Please sign in to comment.