[rygel] media-db: Don't crash on inconsitent database



commit 385152dcb8607e0d5ca70563a1a8c53d4a429f0e
Author: Jens Georg <mail jensge org>
Date:   Sun Mar 14 11:31:26 2010 +0100

    media-db: Don't crash on inconsitent database

 src/rygel/rygel-media-db.vala |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/src/rygel/rygel-media-db.vala b/src/rygel/rygel-media-db.vala
index 7cea5a3..6e5e37a 100644
--- a/src/rygel/rygel-media-db.vala
+++ b/src/rygel/rygel-media-db.vala
@@ -467,11 +467,18 @@ public class Rygel.MediaDB : Object {
             var parent_id = stmt.column_text (18);
             try {
                 var parent = (MediaContainer) get_object (parent_id);
-                children.add (get_object_from_statement (parent,
-                            child_id,
-                            stmt));
-                children[children.size - 1].parent = parent;
-                children[children.size - 1].parent_ref = parent;
+                if (parent != null) {
+                    children.add (get_object_from_statement (parent,
+                                                             child_id,
+                                                             stmt));
+                    children[children.size - 1].parent = parent;
+                    children[children.size - 1].parent_ref = parent;
+                } else {
+                    warning ("Inconsistent database: item %s " +
+                             "has no parent %s",
+                             child_id,
+                             parent_id);
+                }
 
                 return true;
             } catch (DatabaseError e) {



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