# HG changeset patch # User reimar # Date 1390255725 0 # Node ID c11abb0326062dd5d83c707784c126c6cf5e3575 # Parent dd4ceae6520ad2b2eba7bed812ad0b3af2a92639 mplayer: Simplify initial playtree/file code. Also avoids a theoretical NULL dereference if play_tree_iter_step does not return an entry. "Theoretical" since I don't know if or how this case would be possible to trigger, so it might in fact be dead code. diff -r dd4ceae6520a -r c11abb032606 mplayer.c --- a/mplayer.c Mon Jan 20 22:08:44 2014 +0000 +++ b/mplayer.c Mon Jan 20 22:08:45 2014 +0000 @@ -2814,21 +2814,19 @@ mpctx->playtree = m_config_parse_mp_command_line(mconfig, argc, argv); if (mpctx->playtree == NULL) { + // parse error opt_exit = 1; - } else { + } else mpctx->playtree = play_tree_cleanup(mpctx->playtree); - if (mpctx->playtree) { - mpctx->playtree_iter = play_tree_iter_new(mpctx->playtree, mconfig); - if (mpctx->playtree_iter) { - if (play_tree_iter_step(mpctx->playtree_iter, 0, 0) != PLAY_TREE_ITER_ENTRY) { - play_tree_iter_free(mpctx->playtree_iter); - mpctx->playtree_iter = NULL; - } - filename = play_tree_iter_get_file(mpctx->playtree_iter, 1); - } - } + + mpctx->playtree_iter = mpctx->playtree ? play_tree_iter_new(mpctx->playtree, mconfig) : NULL; + if (mpctx->playtree_iter && play_tree_iter_step(mpctx->playtree_iter, 0, 0) != PLAY_TREE_ITER_ENTRY) { + play_tree_iter_free(mpctx->playtree_iter); + mpctx->playtree_iter = NULL; } + filename = mpctx->playtree_iter ? play_tree_iter_get_file(mpctx->playtree_iter, 1) : NULL; + print_version("MPlayer"); #if (defined(__MINGW32__) || defined(__CYGWIN__)) && defined(CONFIG_GUI) void *runningmplayer = FindWindow("MPlayer GUI for Windows", "MPlayer for Windows");