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

Unified Diff: runtime/vm/isolate.cc

Issue 2164703003: Fix for use-after-free of reload context (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: s/test_mode/dont_delete_reload_context/, simplifications Created 4 years, 5 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 | « runtime/vm/isolate.h ('k') | runtime/vm/isolate_reload.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/isolate.cc
diff --git a/runtime/vm/isolate.cc b/runtime/vm/isolate.cc
index c20def45467837153a63515762f8a6c5f22139bb..9b762903934f450e69d151c2d26cd0a1d9a59f3d 100644
--- a/runtime/vm/isolate.cc
+++ b/runtime/vm/isolate.cc
@@ -1085,16 +1085,26 @@ bool Isolate::CanReload() const {
void Isolate::ReportReloadError(const Error& error) {
ASSERT(IsReloading());
reload_context_->AbortReload(error);
- delete reload_context_;
- reload_context_ = NULL;
}
-void Isolate::ReloadSources(bool test_mode) {
+void Isolate::ReloadSources(bool dont_delete_reload_context) {
ASSERT(!IsReloading());
has_attempted_reload_ = true;
- reload_context_ = new IsolateReloadContext(this, test_mode);
+ reload_context_ = new IsolateReloadContext(this);
reload_context_->StartReload();
+ if (dont_delete_reload_context) {
+ // Unit tests use the reload context later. Caller is responsible
+ // for deleting the context.
+ return;
+ }
+ DeleteReloadContext();
+}
+
+
+void Isolate::DeleteReloadContext() {
+ delete reload_context_;
+ reload_context_ = NULL;
}
#endif // !PRODUCT
@@ -1103,20 +1113,12 @@ void Isolate::DoneFinalizing() {
NOT_IN_PRODUCT(
if (IsReloading()) {
reload_context_->FinishReload();
- if (reload_context_->has_error() && reload_context_->test_mode()) {
- // If the reload has an error and we are in test mode keep the reload
- // context on the isolate so that it can be used by unit tests.
- return;
- }
if (reload_context_->has_error()) {
// Remember the reload error.
sticky_reload_error_ = reload_context_->error();
- }
- if (!reload_context_->has_error()) {
+ } else {
reload_context_->ReportSuccess();
}
- delete reload_context_;
- reload_context_ = NULL;
}
)
}
« no previous file with comments | « runtime/vm/isolate.h ('k') | runtime/vm/isolate_reload.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698