From 8e696b9c1ee35f2ce5b9264f31b1963758d65ced Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 15 Oct 2013 15:45:59 +0300 Subject: [PATCH] Avoid closing handles twice --- source/io/unix/handle.cpp | 6 +++++- source/io/windows/handle.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/io/unix/handle.cpp b/source/io/unix/handle.cpp index 9546df9..ea8fa4e 100644 --- a/source/io/unix/handle.cpp +++ b/source/io/unix/handle.cpp @@ -50,7 +50,11 @@ unsigned sys_write(Handle &handle, const char *buf, unsigned size) void sys_close(Handle &handle) { - close(*handle); + if(handle) + { + close(*handle); + *handle = INVALID_HANDLE_VALUE; + } } } // namespace IO diff --git a/source/io/windows/handle.cpp b/source/io/windows/handle.cpp index 5b1d933..17aabb0 100644 --- a/source/io/windows/handle.cpp +++ b/source/io/windows/handle.cpp @@ -35,7 +35,11 @@ unsigned sys_write(Handle &handle, const char *buf, unsigned size) void sys_close(Handle &handle) { - CloseHandle(*handle); + if(handle) + { + CloseHandle(*handle); + *handle = INVALID_HANDLE_VALUE; + } } } // namespace IO -- 2.45.2