[glib] gkeyfile: Clear a variable after freeing it



commit 58f56b24601838d76a8fda7bd48f0ebe0f9758b5
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Mar 21 12:35:25 2016 +0000

    gkeyfile: Clear a variable after freeing it
    
    find_file_in_data_dirs() doesn’t actually clear output_path to NULL on
    failure, so this prevents a use-after-free on that (fd == -1) error
    path.
    
    Spotted by Coverity (CID: #1352981).

 glib/gkeyfile.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c
index a33e686..4b25fd7 100644
--- a/glib/gkeyfile.c
+++ b/glib/gkeyfile.c
@@ -970,6 +970,7 @@ g_key_file_load_from_dirs (GKeyFile       *key_file,
   while (*data_dirs != NULL && !found_file)
     {
       g_free (output_path);
+      output_path = NULL;
 
       fd = find_file_in_data_dirs (file, data_dirs, &output_path,
                                    &key_file_error);


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