Skip to content

Commit 3b7716a

Browse files
aamCommit Queue
authored andcommitted
[gardening] Fix embedder_samples_test leaks, uninitialized variables.
Fixes #59810 TEST=ci Change-Id: I8dca122538195c8aad98e0d0fb64c7ea8e0d2e1a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402421 Reviewed-by: Brian Quinlan <[email protected]> Commit-Queue: Alexander Aprelev <[email protected]>
1 parent a3ef455 commit 3b7716a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

samples/embedder/run_kernel.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ std::string ReadSnapshot(std::string_view path) {
7373

7474
char* bytes = static_cast<char*>(std::malloc(length));
7575
source_file.read(bytes, length);
76-
return std::string(bytes, length);
76+
auto result = std::string(bytes, length);
77+
std::free(bytes);
78+
return result;
7779
}
7880

7981
Dart_Handle ToDartStringList(const std::vector<std::string>& values) {
@@ -122,6 +124,7 @@ int main(int argc, char** argv) {
122124

123125
// Start an isolate from a platform kernel.
124126
Dart_IsolateFlags isolate_flags;
127+
Dart_IsolateFlagsInitialize(&isolate_flags);
125128

126129
Dart_CreateIsolateGroupFromKernel(
127130
/*script_uri=*/snapshot_uri.c_str(),

0 commit comments

Comments
 (0)