[rygel/wip/phako/remove-warnings: 11/14] media-export: Fix potential null access warnings



commit 8607ccf02b80e38b34275874df6e9e0b74c5e3bf
Author: Jens Georg <mail jensge org>
Date:   Fri Feb 14 00:26:45 2020 +0100

    media-export: Fix potential null access warnings

 src/plugins/media-export/rygel-media-export-harvesting-task.vala | 8 ++++----
 src/plugins/media-export/rygel-media-export-media-cache.vala     | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala 
b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index a3f92272..0a28acc9 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -221,7 +221,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
             var dummy_parent = parent as DummyContainer;
             if (dummy_parent == null ||
                 !dummy_parent.children.contains (MediaCache.get_id (file))) {
-                (parent as TrackableContainer).add_child_tracked.begin (container);
+                ((TrackableContainer) parent).add_child_tracked.begin (container);
             }
 
             return true;
@@ -248,7 +248,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
     }
 
     private async void enumerate_directory () {
-        var directory = (this.containers.peek_head () as DummyContainer).file;
+        var directory = ((DummyContainer) this.containers.peek_head ()).file;
         try {
             var enumerator = yield directory.enumerate_children_async
                                         (HARVESTER_ATTRIBUTES,
@@ -335,9 +335,9 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
                 // This is only necessary to generate the proper <objAdd LastChange
                 // entry
                 if (this.files.peek ().known) {
-                    (item as UpdatableObject).non_overriding_commit.begin ();
+                    ((UpdatableObject) item).non_overriding_commit.begin ();
                 } else {
-                    var container = item.parent as TrackableContainer;
+                    var container = (TrackableContainer) item.parent;
                     container.add_child_tracked.begin (item) ;
                 }
             }
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala 
b/src/plugins/media-export/rygel-media-export-media-cache.vala
index c095d9b7..a0a4e92b 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -952,9 +952,10 @@ public class Rygel.MediaExport.MediaCache : Object {
 
         if (object != null) {
             object.modified = statement.column_int64 (DetailColumn.TIMESTAMP);
-            if (object.modified  == int64.MAX && object is MediaFileItem) {
+            var item = object as MediaFileItem;
+            if (object.modified  == int64.MAX && item != null) {
                 object.modified = 0;
-                (object as MediaFileItem).place_holder = true;
+                item.place_holder = true;
             }
             object.object_update_id = (uint) statement.column_int64
                                         (DetailColumn.OBJECT_UPDATE_ID);


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