From 7294d8b5af3d94c919271199edf1285ff335ccb3 Mon Sep 17 00:00:00 2001 From: Catherine Date: Wed, 8 May 2024 00:27:28 +0000 Subject: [PATCH] cxxrtl: fix close of invalid fd in spool destructor. --- backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h b/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h index b8233b007..9aa3e105d 100644 --- a/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h +++ b/backends/cxxrtl/runtime/cxxrtl/cxxrtl_replay.h @@ -512,9 +512,10 @@ public: spool &operator=(const spool &) = delete; ~spool() { - if (int fd = writefd.exchange(-1)) + int fd; + if ((fd = writefd.exchange(-1)) != -1) close(fd); - if (int fd = readfd.exchange(-1)) + if ((fd = readfd.exchange(-1)) != -1) close(fd); }