[rhythmbox] rhythmdb: don't crash when processing certain load errors (bug #587479)



commit 453b62df94d833ff27b70e62c3deb17b42c7ad6e
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Jul 1 10:44:19 2009 +1000

    rhythmdb: don't crash when processing certain load errors (bug #587479)
    
    Some metadata load events don't end up having a metadata reader
    instance, but in some places we assumed they all did.

 rhythmdb/rhythmdb.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/rhythmdb/rhythmdb.c b/rhythmdb/rhythmdb.c
index 3344e28..debda4f 100644
--- a/rhythmdb/rhythmdb.c
+++ b/rhythmdb/rhythmdb.c
@@ -2281,7 +2281,6 @@ rhythmdb_process_metadata_load_real (RhythmDBEvent *event)
 	RhythmDBEntry *entry;
 	GValue value = {0,};
 	GTimeVal time;
-	const char *media_type;
 
 	if (event->entry_type == RHYTHMDB_ENTRY_TYPE_INVALID)
 		event->entry_type = RHYTHMDB_ENTRY_TYPE_SONG;
@@ -2293,12 +2292,13 @@ rhythmdb_process_metadata_load_real (RhythmDBEvent *event)
 	 * otherwise, add an import error entry if there was an error,
 	 * or just ignore it if it doesn't contain audio.
 	 */
-
-	media_type = rb_metadata_get_mime (event->metadata);
-	if (rb_metadata_has_video (event->metadata) ||
-	    (media_type != NULL && rhythmdb_ignore_media_type (media_type))) {
-		rhythmdb_add_import_error_entry (event->db, event, event->ignore_type);
-		return TRUE;
+	if (event->metadata != NULL) {
+		const char *media_type = rb_metadata_get_mime (event->metadata);
+		if (rb_metadata_has_video (event->metadata) ||
+		    (media_type != NULL && rhythmdb_ignore_media_type (media_type))) {
+			rhythmdb_add_import_error_entry (event->db, event, event->ignore_type);
+			return TRUE;
+		}
 	}
 
 	/* also ignore really small files we can't identify */
@@ -2480,10 +2480,11 @@ rhythmdb_process_metadata_load (RhythmDB *db,
 				RhythmDBEvent *event)
 {
 	/* only process missing plugins for audio files */
-	if (event->metadata != NULL &&
-	    rb_metadata_has_audio (event->metadata) == TRUE &&
-	    rb_metadata_has_video (event->metadata) == FALSE &&
-	    rb_metadata_has_missing_plugins (event->metadata) == TRUE) {
+	if (event->metadata == NULL) {
+		/* obviously can't process missing plugins here */
+	} else if (rb_metadata_has_audio (event->metadata) == TRUE &&
+		   rb_metadata_has_video (event->metadata) == FALSE &&
+		   rb_metadata_has_missing_plugins (event->metadata) == TRUE) {
 		char **missing_plugins;
 		char **plugin_descriptions;
 		GClosure *closure;



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