core: Prevent crash on missing element
authorJens Georg <mail@jensge.org>
Sun, 18 Mar 2012 13:19:52 +0000 (14:19 +0100)
committerJens Georg <mail@jensge.org>
Sun, 18 Mar 2012 13:21:12 +0000 (14:21 +0100)
src/rygel/rygel-http-identity-handler.vala

index 0981bd0..845fe32 100644 (file)
@@ -83,15 +83,16 @@ internal class Rygel.HTTPIdentityHandler : Rygel.HTTPGetHandler {
         } else {
             src = request.item.create_stream_source
                                         (request.http_server.context.host_ip);
-            if (src.is_floating ()) {
-                src.ref_sink ();
-            }
         }
 
         if (src == null) {
             throw new HTTPRequestError.NOT_FOUND (_("Not found"));
         }
 
+        if (src.is_floating ()) {
+            src.ref_sink ();
+        }
+
         return new HTTPResponse (request, this, src);
     }
 }