From 381b4ed77c3b11efa5e7619253133146a44df911 Mon Sep 17 00:00:00 2001 From: José Bollo Date: Tue, 28 Nov 2017 09:54:36 +0100 Subject: Fix a crash when playing empty list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4037ab08715bea231bb8e9d725ffba9718c7daca Signed-off-by: José Bollo --- binding/afm-mediaplayer-binding.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index 9c41f27..2e3bef2 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -188,7 +188,8 @@ static void populate_playlist(json_object *jquery) if (current_track == NULL) { current_track = g_list_first(playlist); - set_media_uri(current_track->data); + if (current_track && current_track->data) + set_media_uri(current_track->data); } } @@ -226,7 +227,7 @@ static void audio_playlist(struct afb_req request) populate_playlist(jquery); if (playlist == NULL) - afb_req_fail(request, "failed", "invalid playlist"); + afb_req_fail(request, "failed", "invalid playlist"); else afb_req_success(request, NULL, NULL); @@ -331,7 +332,13 @@ static void controls(struct afb_req request) g_object_get(data.playbin, "audio-sink", &obj, NULL); if (obj == data.fake_sink) { - set_media_uri(current_track->data); + if (current_track && current_track->data) + set_media_uri(current_track->data); + else { + pthread_mutex_unlock(&mutex); + afb_req_fail(request, "failed", "No playlist"); + return; + } } else { g_object_set(data.playbin, "audio-sink", data.alsa_sink, NULL); gst_element_set_state(data.playbin, GST_STATE_PLAYING); -- cgit 1.2.3-korg