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

Unified Diff: runtime/vm/unit_test.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_reload.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/unit_test.cc
diff --git a/runtime/vm/unit_test.cc b/runtime/vm/unit_test.cc
index 0cf5685ed390a8886be8e1374990c96b1c45761b..522974e6170c97dccbaa5ffc778b9b82f572401f 100644
--- a/runtime/vm/unit_test.cc
+++ b/runtime/vm/unit_test.cc
@@ -269,7 +269,7 @@ Dart_Handle TestCase::TriggerReload() {
{
TransitionNativeToVM transition(Thread::Current());
- isolate->ReloadSources(/* test_mode = */ true);
+ isolate->ReloadSources(/* dont_delete_reload_context = */ true);
}
return Dart_FinalizeLoading(false);
@@ -279,9 +279,8 @@ Dart_Handle TestCase::TriggerReload() {
Dart_Handle TestCase::GetReloadErrorOrRootLibrary() {
Isolate* isolate = Isolate::Current();
- if (isolate->reload_context() != NULL) {
- // We should only have a reload context hanging around if an error occurred.
- ASSERT(isolate->reload_context()->has_error());
+ if (isolate->reload_context() != NULL &&
+ isolate->reload_context()->has_error()) {
// Return a handle to the error.
return Api::NewHandle(Thread::Current(),
isolate->reload_context()->error());
@@ -298,7 +297,14 @@ Dart_Handle TestCase::ReloadTestScript(const char* script) {
return result;
}
- return GetReloadErrorOrRootLibrary();
+ result = GetReloadErrorOrRootLibrary();
+
+ Isolate* isolate = Isolate::Current();
+ if (isolate->reload_context() != NULL) {
+ isolate->DeleteReloadContext();
+ }
+
+ return result;
}
« no previous file with comments | « runtime/vm/isolate_reload.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698