Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Be more defensive against broken parameters.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 26 Mar 2012 16:28:45 +0000 (18:28 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 26 Mar 2012 17:07:04 +0000 (19:07 +0200)
Don't crash unnecessarily if argv[argc] doesn't exist.

src/xbt/log.c

index 0e78015..b5fdebf 100644 (file)
@@ -568,8 +568,10 @@ void xbt_log_init(int *argc, char **argv)
       argv[j++] = argv[i];
     }
   }
-  argv[j] = NULL;
-  *argc = j;
+  if (j < *argc) {
+    argv[j] = NULL;
+    *argc = j;
+  }
 }
 
 static void log_cat_exit(xbt_log_category_t cat)