From ffb8b354240cc4f4c423d47418619fc4c8b931d6 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Fri, 11 Apr 2014 12:43:59 -0700 Subject: [PATCH] cleanup: avoid dereferencing NULL pointers --- playlist.c | 9 ++++++--- upnphttp.c | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/playlist.c b/playlist.c index d1478e6..508c4c3 100644 --- a/playlist.c +++ b/playlist.c @@ -221,9 +221,12 @@ found: if( !last_dir ) { last_dir = sql_get_text_field(db, "SELECT PATH from DETAILS where ID = %lld", detailID); - fname = strrchr(last_dir, '/'); - if( fname ) - *fname = '\0'; + if( last_dir ) + { + fname = strrchr(last_dir, '/'); + if( fname ) + *fname = '\0'; + } last_hash = hash; } found++; diff --git a/upnphttp.c b/upnphttp.c index 0743b44..ef9a279 100644 --- a/upnphttp.c +++ b/upnphttp.c @@ -1813,8 +1813,13 @@ SendResp_dlnafile(struct upnphttp *h, char *object) { char *art; art = sql_get_text_field(db, "SELECT ALBUM_ART from DETAILS where ID = '%lld'", id); - SendResp_albumArt(h, art); - sqlite3_free(art); + if (art) + { + SendResp_albumArt(h, art); + sqlite3_free(art); + } + else + Send404(h); return; } }