summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2015-04-19 14:40:33 +0200
committerJens Georg <mail@jensge.org>2015-04-19 15:22:25 +0200
commitb187e0982cd303f73ac2e50d743f0db82b91d6f9 (patch)
tree83aacecb12ef2a9619475d144f5148f9cd4fa3a6
parent2c8cf0bdccad47f97e207ac4e1bedd06cd6b346b (diff)
downloadrygel-b187e0982cd303f73ac2e50d743f0db82b91d6f9.tar.gz
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.
-rw-r--r--src/librygel-server/rygel-thumbnailer.vala6
-rw-r--r--src/librygel-server/rygel-visual-item.vala2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/librygel-server/rygel-thumbnailer.vala b/src/librygel-server/rygel-thumbnailer.vala
index f502161a..1b291bae 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 ed12329c..552862e5 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);