commit af96c2c1b20383684b1ec2084dab7936f7053031 Author: Ethan A Merritt Date: Tue Jan 14 20:56:37 2025 -0800 x11: protect against double fclose() if two errors in a row Bug 2753 diff --git term/x11.trm term/x11.trm index 18ad4ad85..cbe01dd0e 100644 --- term/x11.trm +++ term/x11.trm @@ -854,8 +854,9 @@ X11_atexit() /* dont wait(), since they might be -persist */ X11_ipc = NULL; #ifdef PIPE_IPC - close(ipc_back_fd); - ipc_back_fd = -1; + if (ipc_back_fd >= 0) + close(ipc_back_fd); + ipc_back_fd = IPC_BACK_CLOSED; #endif } } @@ -1374,7 +1375,8 @@ X11_graphics() #ifdef PIPE_IPC /* if we know the outboard driver has stopped, restart it */ if (ipc_back_fd == IPC_BACK_CLOSED) { - fclose(X11_ipc); + if (X11_ipc > 0) + fclose(X11_ipc); X11_ipc = NULL; X11_init(); }