ref: 7539ef43361f1579bd03b0b4007465adb8872aa0
parent: 47176077d8ba8fdedafc56c1f02c99ddba48d463
author: glenda <glenda@cirno>
date: Sun Mar 23 05:34:24 EDT 2025
harden wclose in case of concurrently updating history and closing the window
--- a/wind.c
+++ b/wind.c
@@ -1503,14 +1503,24 @@
return 0;
if(i < 0)
error("negative ref count");
+
+ /* we might get receieve multiple close requests */
if(w->history) {
for(i = 0; i < w->nhistory; i++)
free(w->history[i]);
free(w->history);
free(w->historylens);
+ w->history = nil;
+ w->historylens = nil;
+ w->nhistory = 0;
}
- if(w->savedcmd)
+
+ if(w->savedcmd) {
free(w->savedcmd);
+ w->savedcmd = nil;
+ w->nsavedcmd = 0;
+ }
+
wclunk(w);
wsendctlmesg(w, Exited, ZR, nil);
return 1;