Skip to content

Commit 91d53d4

Browse files
committed
FDInputStream: guard descriptor close
1 parent ed399cc commit 91d53d4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/Common/FDInputStream.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ namespace usbguard
5757
{
5858
public:
5959
FDStreamBuf(int fd) : fd_(fd) { }
60-
~FDStreamBuf() override { close(fd_); }
60+
~FDStreamBuf() override {
61+
if (fd_ >= 0) {
62+
close(fd_);
63+
fd_ = -1;
64+
}
65+
}
6166

6267
std::streamsize xsgetn(char* s, std::streamsize n)
6368
{

0 commit comments

Comments
 (0)