FDIO: check for double freeing of an FDIO resource to fix possible double close ...
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 15 Aug 2013 21:25:32 +0000 (23:25 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 15 Aug 2013 21:25:32 +0000 (23:25 +0200)
libcitadel/lib/stringbuf.c

index bd67e0d..9bc1c8e 100644 (file)
@@ -3955,14 +3955,17 @@ void FDIOBufferDelete(FDIOBuffer *FDB)
 #ifdef LINUX_SPLICE
        if (EnableSplice)
        {
 #ifdef LINUX_SPLICE
        if (EnableSplice)
        {
-               close(FDB->SplicePipe[0]);
-               close(FDB->SplicePipe[1]);
+               if (FDB->SplicePipe[0] > 0)
+                       close(FDB->SplicePipe[0]);
+               if (FDB->SplicePipe[1] > 0)
+                       close(FDB->SplicePipe[1]);
        }
        else
 #endif
                FreeStrBuf(&FDB->ChunkBuffer);
        
        }
        else
 #endif
                FreeStrBuf(&FDB->ChunkBuffer);
        
-       close(FDB->OtherFD);
+       if (FDB->OtherFD > 0)
+               close(FDB->OtherFD);
        memset(FDB, 0, sizeof(FDIOBuffer));     
 }
 
        memset(FDB, 0, sizeof(FDIOBuffer));     
 }