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

Unified Diff: runtime/bin/gen_snapshot.cc

Issue 11192065: Fix error exit path so that it frees the buffer before exiting the program. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 2 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: runtime/bin/gen_snapshot.cc
===================================================================
--- runtime/bin/gen_snapshot.cc (revision 13789)
+++ runtime/bin/gen_snapshot.cc (working copy)
@@ -18,6 +18,7 @@
#define CHECK_RESULT(result) \
if (Dart_IsError(result)) { \
+ free(snapshot_buffer); \
fprintf(stderr, "Error: %s", Dart_GetError(result)); \
Dart_ExitScope(); \
Dart_ShutdownIsolate(); \
@@ -30,6 +31,7 @@
static const char* snapshot_filename = NULL;
static bool script_snapshot = false;
static const char* package_root = NULL;
+static uint8_t* snapshot_buffer = NULL;
// Global state which contains a pointer to the script name for which
@@ -343,7 +345,7 @@
CHECK_RESULT(result);
// Save the snapshot buffer as we are about to shutdown the isolate.
- uint8_t* snapshot_buffer = reinterpret_cast<uint8_t*>(malloc(size));
+ snapshot_buffer = reinterpret_cast<uint8_t*>(malloc(size));
ASSERT(snapshot_buffer != NULL);
memmove(snapshot_buffer, buffer, size);
@@ -360,6 +362,7 @@
if (isolate == NULL) {
fprintf(stderr, "%s", error);
free(error);
+ free(snapshot_buffer);
exit(255);
}
Dart_EnterScope();
« 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