]> git.tdb.fi Git - libs/core.git/commitdiff
Avoid closing handles twice
authorMikko Rasa <tdb@tdb.fi>
Tue, 15 Oct 2013 12:45:59 +0000 (15:45 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 15 Oct 2013 12:45:59 +0000 (15:45 +0300)
source/io/unix/handle.cpp
source/io/windows/handle.cpp

index 9546df9f579c657f61f658ee235db3e172eec7dd..ea8fa4eeb9797e12f5a598f4c63d0fe6e352d492 100644 (file)
@@ -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
index 5b1d93368f3386adeab823b1c67c121a1cbd3264..17aabb080bb113c3e8e35a59f5cb7ae2f5fdafef 100644 (file)
@@ -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