summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c6
1 files changed, 4 insertions, 2 deletions
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;
}
}