summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
Diffstat (limited to 'rts')
-rw-r--r--rts/CheckUnload.c3
-rw-r--r--rts/Linker.c6
2 files changed, 6 insertions, 3 deletions
diff --git a/rts/CheckUnload.c b/rts/CheckUnload.c
index f1f454ceaf..98f184b84c 100644
--- a/rts/CheckUnload.c
+++ b/rts/CheckUnload.c
@@ -298,7 +298,7 @@ void checkUnload (StgClosure *static_objects)
// marked as unreferenced can be physically unloaded, because we
// have no references to it.
prev = NULL;
- for (oc = unloaded_objects; oc; prev = oc, oc = next) {
+ for (oc = unloaded_objects; oc; oc = next) {
next = oc->next;
if (oc->referenced == 0) {
if (prev == NULL) {
@@ -312,6 +312,7 @@ void checkUnload (StgClosure *static_objects)
} else {
IF_DEBUG(linker, debugBelch("Object file still in use: %"
PATH_FMT "\n", oc->fileName));
+ prev = oc;
}
}
diff --git a/rts/Linker.c b/rts/Linker.c
index af26d74a57..ab235e9f5c 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -3016,8 +3016,8 @@ unloadObj( pathchar *path )
IF_DEBUG(linker, debugBelch("unloadObj: %" PATH_FMT "\n", path));
prev = NULL;
- for (oc = objects; oc; prev = oc, oc = next) {
- next = oc->next;
+ for (oc = objects; oc; oc = next) {
+ next = oc->next; // oc might be freed
if (!pathcmp(oc->fileName,path)) {
@@ -3075,6 +3075,8 @@ unloadObj( pathchar *path )
/* This could be a member of an archive so continue
* unloading other members. */
unloadedAnyObj = HS_BOOL_TRUE;
+ } else {
+ prev = oc;
}
}