From 733dabb37eff4d9d26205837483964b2af82dd4b Mon Sep 17 00:00:00 2001 From: siretart Date: Fri, 13 Aug 2010 15:58:11 +0000 Subject: playtree: fix segfault on empty playlist Add a sanity check to avoid a segmentation fault in playtree.c on empty playlists. This is Debian Bug: http://bugs.debian.org/591525 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31960 b3059339-0415-0410-9bf9-f77b7e298cf2 --- playtree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'playtree.c') diff --git a/playtree.c b/playtree.c index c8a3cdf916..42762064c2 100644 --- a/playtree.c +++ b/playtree.c @@ -218,8 +218,15 @@ void play_tree_set_child(play_tree_t* pt, play_tree_t* child) { play_tree_t* iter; + /* Roughly validate input data. Both, pt and child are going to be + * dereferenced, hence assure they're not NULL. + */ + if (!pt || !child) { + mp_msg(MSGT_PLAYTREE, MSGL_ERR, "Internal error, attempt to add an empty child or use empty playlist\n"); + return; + } + #ifdef MP_DEBUG - assert(pt != NULL); assert(pt->entry_type == PLAY_TREE_ENTRY_NODE); #endif -- cgit v1.2.3