[glib/glib-2-56] W32 gstdio: don't close fd handle



commit 9200ba1ea76e8c1595143d89c9851f679dc89355
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Wed Apr 11 12:48:06 2018 +0000

    W32 gstdio: don't close fd handle
    
    If a handle was obtained from a fd that we got from up the stack,
    we shouldn't call CloseHandle() on it in case of an error.
    
    This is a bug. Luckily, it happens only on the error codepath, so,
    hopefully, no one had hit it yet.

 glib/gstdio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/glib/gstdio.c b/glib/gstdio.c
index 858d56999..9b674d753 100644
--- a/glib/gstdio.c
+++ b/glib/gstdio.c
@@ -199,7 +199,8 @@ _g_win32_stat_utf16_no_trailing_slashes (const gunichar2    *filename,
 
   if (!succeeded_so_far)
     {
-      CloseHandle (file_handle);
+      if (fd < 0)
+        CloseHandle (file_handle);
       errno = w32_error_to_errno (error_code);
       return -1;
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]