[glib/glib-2-56] W32: check filename for being NULL in g_stat()



commit 0bc1e98af6f6ed2f4a5f05f495b0c9a001dc370f
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date:   Tue May 22 16:43:35 2018 +0000

    W32: check filename for being NULL in g_stat()
    
    Previous version of this function started with a call to g_utf8_to_utf16(),
    which also served as a NULL check, since g_utf8_to_utf16() just returns NULL
    on NULL strings. Current version of this function does some filename string
    checks first and converts it to utf16 only after these checks are done, and
    these checks do not take into account the possibility of filename being NULL.
    
    Fix this by explicitly checking for NULL.

 glib/gstdio.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/glib/gstdio.c b/glib/gstdio.c
index a374d9a51..e158de223 100644
--- a/glib/gstdio.c
+++ b/glib/gstdio.c
@@ -365,6 +365,12 @@ _g_win32_stat_utf8 (const gchar       *filename,
   int result;
   gsize len;
 
+  if (filename == NULL)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
   len = strlen (filename);
 
   while (len > 0 && G_IS_DIR_SEPARATOR (filename[len - 1]))


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