[easytag] Set the GError in et_id3tag_check_if_file_is_valid



commit 6c50d0e0242a32b0b8fdca588cd15d98c7ce2e07
Author: David King <amigadave amigadave com>
Date:   Sat Feb 14 20:12:37 2015 +0000

    Set the GError in et_id3tag_check_if_file_is_valid
    
    If the file was empty, but there were otherwise no errors when reading
    the file, the GError was left unset. This caused a crash, when reading
    the error message for display to the user and dereferencing a NULL
    pointer.

 src/tags/id3_tag.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/tags/id3_tag.c b/src/tags/id3_tag.c
index 7dd65ac..f27627e 100644
--- a/src/tags/id3_tag.c
+++ b/src/tags/id3_tag.c
@@ -1426,9 +1426,16 @@ et_id3tag_check_if_file_is_valid (GFile *file, GError **error)
         }
     }
 
-    g_assert (error == NULL || *error == NULL);
     g_object_unref (file_istream);
 
+    /* The error was not set by g_input_stream_read(), so the file must be
+     * empty. */
+    if (!valid)
+    {
+        g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "%s",
+                     "Input truncated or empty");
+    }
+
     return valid;
 }
 


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