[glib] gfileutils: add some sanity checks



commit 21d2c646607ef1d1b173ddb83dc2b99805ca50fc
Author: Aurélien Zanelli <aurelien zanelli darkosphere fr>
Date:   Mon Aug 24 16:07:32 2015 +0200

    gfileutils: add some sanity checks
    
    To avoid handling non-null GError or NULL filename.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=754026

 glib/gfileutils.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index e995c4a..a2951cc 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1609,6 +1609,8 @@ g_file_open_tmp (const gchar  *tmpl,
   gchar *fulltemplate;
   gint result;
 
+  g_return_val_if_fail (error == NULL || *error == NULL, -1);
+
   result = g_get_tmp_name (tmpl, &fulltemplate,
                            wrap_g_open,
                            O_CREAT | O_EXCL | O_RDWR | O_BINARY,
@@ -1656,6 +1658,8 @@ g_dir_make_tmp (const gchar  *tmpl,
 {
   gchar *fulltemplate;
 
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
   if (g_get_tmp_name (tmpl, &fulltemplate, wrap_g_mkdir, 0, 0700, error) == -1)
     return NULL;
   else
@@ -2053,7 +2057,10 @@ g_file_read_link (const gchar  *filename,
   size_t size;
   ssize_t read_size;
   
-  size = 256; 
+  g_return_val_if_fail (filename != NULL, NULL);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
+  size = 256;
   buffer = g_malloc (size);
   
   while (TRUE) 
@@ -2080,6 +2087,9 @@ g_file_read_link (const gchar  *filename,
       buffer = g_realloc (buffer, size);
     }
 #else
+  g_return_val_if_fail (filename != NULL, NULL);
+  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
+
   g_set_error_literal (error,
                        G_FILE_ERROR,
                        G_FILE_ERROR_INVAL,


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