[rygel/rygel-0-26] server: Prevent crash on thumbnail



commit 10ec947d3d6aed1275cefe48f59468f8b36057f5
Author: Jens Georg <mail jensge org>
Date:   Sun Apr 19 14:40:33 2015 +0200

    server: Prevent crash on thumbnail
    
    If the VisualItem does not have a mime type, the old code would add a "null"
    thumbnail to the list which would be dereferenced on serialisation.

 src/librygel-server/rygel-thumbnailer.vala |    6 +++---
 src/librygel-server/rygel-visual-item.vala |    4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/librygel-server/rygel-thumbnailer.vala b/src/librygel-server/rygel-thumbnailer.vala
index f502161..1b291ba 100644
--- a/src/librygel-server/rygel-thumbnailer.vala
+++ b/src/librygel-server/rygel-thumbnailer.vala
@@ -67,7 +67,7 @@ internal class Rygel.Thumbnailer : GLib.Object {
         return thumbnailer;
     }
 
-    public Thumbnail get_thumbnail (string uri, string mime_type) throws Error {
+    public Thumbnail get_thumbnail (string uri, string? mime_type) throws Error {
         var file = File.new_for_uri (uri);
         if (!file.is_native ()) {
             throw new ThumbnailerError.NO_THUMBNAIL
@@ -90,11 +90,11 @@ internal class Rygel.Thumbnailer : GLib.Object {
 
         // Send a request to create thumbnail if it does not exist, signal
         // that there's no thumbnail available now.
-        if (this.thumbler != null && path == null) {
+        if (this.thumbler != null && path == null && mime_type != null) {
             this.thumbler.queue_thumbnail_task (uri, mime_type);
 
             throw new ThumbnailerError.NO_THUMBNAIL
-                                        (_("No thumbnail available"));
+                                        (_("No thumbnail available. Generation requested."));
         }
 
         if (path == null) {
diff --git a/src/librygel-server/rygel-visual-item.vala b/src/librygel-server/rygel-visual-item.vala
index ed12329..bdb317a 100644
--- a/src/librygel-server/rygel-visual-item.vala
+++ b/src/librygel-server/rygel-visual-item.vala
@@ -61,7 +61,7 @@ public interface Rygel.VisualItem : MediaFileItem {
         // Lets see if we can provide the thumbnails
         var thumbnailer = Thumbnailer.get_default ();
 
-        if (thumbnailer != null) {
+        if (thumbnailer != null && this.mime_type != null) {
             try {
                 var thumb = thumbnailer.get_thumbnail (uri, this.mime_type);
                 this.thumbnails.add (thumb);
@@ -79,6 +79,8 @@ public interface Rygel.VisualItem : MediaFileItem {
 
     internal void add_thumbnail_resources (HTTPServer http_server) {
         for (var i = 0; i < this.thumbnails.size; i++) {
+            warning ("Thumbnail is %p for %d/%d", this.thumbnails.get (i), i,
+                     this.thumbnails.size);
             if (!this.place_holder) {
                 var thumbnail = this.thumbnails.get (i);
                 // Add the defined thumbnail uri unconditionally


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