aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/wind.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-07-28 04:47:00 +0000
committerrsc <devnull@localhost>2005-07-28 04:47:00 +0000
commit725d9fd7952a63c09f50d5544d0b306177462d43 (patch)
treeb5f84ac5821f7ae0d351496561cddac7f15a1e75 /src/cmd/acme/wind.c
parent34e8254fb8cc206664fc9dcba3c7c8ae1de6ab85 (diff)
downloadplan9port-725d9fd7952a63c09f50d5544d0b306177462d43.tar.gz
plan9port-725d9fd7952a63c09f50d5544d0b306177462d43.tar.bz2
plan9port-725d9fd7952a63c09f50d5544d0b306177462d43.zip
winunlock bug
Diffstat (limited to 'src/cmd/acme/wind.c')
-rw-r--r--src/cmd/acme/wind.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/acme/wind.c b/src/cmd/acme/wind.c
index 5d409a98..2f015feb 100644
--- a/src/cmd/acme/wind.c
+++ b/src/cmd/acme/wind.c
@@ -145,7 +145,6 @@ winlock(Window *w, int owner)
int i;
File *f;
-//fprint(2, "winlock %p %d %lux\n", w, owner, getcallerpc(&w));
f = w->body.file;
for(i=0; i<f->ntext; i++)
winlock1(f->text[i]->w, owner);
@@ -157,16 +156,17 @@ winunlock(Window *w)
int i;
File *f;
-//fprint(2, "winunlock %p %lux\n", w, getcallerpc(&w));
+ /*
+ * subtle: loop runs backwards to avoid tripping over
+ * winclose indirectly editing f->text and freeing f
+ * on the last iteration of the loop.
+ */
f = w->body.file;
- for(i=0; i<f->ntext; i++){
+ for(i=f->ntext-1; i>=0; i--){
w = f->text[i]->w;
w->owner = 0;
qunlock(&w->lk);
winclose(w);
- /* winclose() can change up f->text; beware */
- if(f->ntext>0 && w != f->text[i]->w)
- --i; /* winclose() deleted window */
}
}