changeset 8426:ca2813aafb35

more i+1<argc checks patch by "Puk Madick" <pingy@swirvemail.com>, correction by Albeu
author arpi
date Wed, 11 Dec 2002 20:56:37 +0000
parents 58063f77aa4d
children 878952081187
files parser-mpcmd.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/parser-mpcmd.c	Wed Dec 11 20:48:51 2002 +0000
+++ b/parser-mpcmd.c	Wed Dec 11 20:56:37 2002 +0000
@@ -238,7 +238,7 @@
 	  m_option_t* mp_opt = NULL;
 	  play_tree_t* entry = NULL;
 
-	  tmp = is_entry_option(opt,argv[i + 1],&entry);
+	  tmp = (i+1<argc) ? is_entry_option(opt,argv[i + 1],&entry) : 0;
 	  if(tmp > 0)  { // It's an entry
 	    if(entry) {
 	      add_entry(entry);
@@ -251,9 +251,10 @@
 	    mp_opt = m_config_get_option(config,opt);
 	    if (mp_opt != NULL) { // Option exist
 	      if(mode == GLOBAL || (mp_opt->flags & M_OPT_GLOBAL))
-		tmp = m_config_set_option(config, opt, argv[i + 1]);
+                tmp = (i+1<argc) ? m_config_set_option(config, opt, argv[i + 1])
+				 : m_config_set_option(config, opt, NULL);
 	      else {
-		tmp = m_config_check_option(config, opt, argv[i + 1]);
+		tmp = (i+1<argc) ? m_config_check_option(config, opt, argv[i + 1]) : -1;
 		if(tmp >= 0 && mode != DROP_LOCAL) {
 		  play_tree_t* pt = last_entry ? last_entry : last_parent;
 		  play_tree_set_param(pt,opt, argv[i + 1]);