[rygel] server: Prevent crash on thumbnail
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] server: Prevent crash on thumbnail
- Date: Sun, 19 Apr 2015 13:22:35 +0000 (UTC)
commit b187e0982cd303f73ac2e50d743f0db82b91d6f9
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 | 2 +-
2 files changed, 4 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..552862e 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]