1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Fix command line parsing regression

This commit is contained in:
Moritz Grimm 2015-05-06 16:59:05 +00:00
parent 43e48648fa
commit 05c7e32997
2 changed files with 5 additions and 3 deletions

View File

@ -171,7 +171,7 @@ cfg_set_program_name(const char *progname, const char **errstrp)
int int
cfg_set_program_config_type(enum cfg_config_type type, const char **errstrp) cfg_set_program_config_type(enum cfg_config_type type, const char **errstrp)
{ {
if (type >= CFG_TYPE_MAX) { if (CFG_TYPE_MIN > type || CFG_TYPE_MAX < type) {
if (NULL != errstrp) if (NULL != errstrp)
*errstrp = "invalid"; *errstrp = "invalid";
return (-1); return (-1);

View File

@ -20,6 +20,7 @@
#include "compat.h" #include "compat.h"
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
@ -105,8 +106,9 @@ cmdline_parse(int argc, char *argv[], int *ret_p)
switch (ch) { switch (ch) {
case OPT_CONFIGFILE: case OPT_CONFIGFILE:
if (0 > cfg_set_program_config_file(optarg, &err_str) || assert(0 == cfg_set_program_config_type(CFG_TYPE_XMLFILE,
0 > cfg_set_program_config_type(CFG_TYPE_XMLFILE, NULL)) { NULL));
if (0 > cfg_set_program_config_file(optarg, &err_str)) {
fprintf(stderr, "-%c: argument %s\n", fprintf(stderr, "-%c: argument %s\n",
OPT_CONFIGFILE, err_str); OPT_CONFIGFILE, err_str);
_usage(); _usage();