changeset 31879:253f7779fe98

sanity check to avoid a segmentation fault in playtree.c on empty playlists. This is Debian Bug: http://bugs.debian.org/591525
author siretart
date Fri, 13 Aug 2010 15:58:11 +0000
parents e9458f705c3f
children 4f837c9acc58
files playtree.c
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/playtree.c	Fri Aug 13 11:08:30 2010 +0000
+++ b/playtree.c	Fri Aug 13 15:58:11 2010 +0000
@@ -218,8 +218,15 @@
 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