fix potential segfault in para_client
[paraslash.git] / grab_client.c
index 2a98b35f8831210280321cbb3a48ff984996dd65..2dfb295b8ce87fcb5f165bcfd4b3c25f3bdb5b50 100644 (file)
 #include "error.h"
 #include "string.h"
 
-
-/** this maps the enum to the text used at the command line */
-static const char *gc_modes[] = {
-       [GRAB_PEDANTIC] = "pedantic",
-       [GRAB_SLOPPY] = "sloppy",
-       [GRAB_AGGRESSIVE] = "aggressive",
-       NULL
-};
-
 /** grab clients that are not yet attached to a filter node */
 struct list_head inactive_grab_client_list;
 
@@ -99,13 +90,12 @@ static int check_gc_args(struct grab_client *gc)
 {
        int i;
        struct grab_client_args_info *conf = gc->conf;
+       char **mv = grab_client_cmdline_parser_mode_values;
 
        PARA_INFO_LOG("filter_num: %d\n", gc->conf->filter_num_arg);
-       for (i = 0; gc_modes[i]; i++)
-               if (!strcmp(conf->mode_arg, gc_modes[i]))
+       for (i = 0; mv[i]; i++)
+               if (!strcmp(conf->mode_arg, mv[i]))
                        break;
-       if (!gc_modes[i])
-               return -E_INVALID_GRAB_MODE;
        gc->mode = i;
        if (conf->audio_format_given) {
                gc->audio_format_num = get_audio_format_num(conf->audio_format_arg);
@@ -263,6 +253,9 @@ __malloc struct grab_client *grab_client_new(int fd, int argc, char **argv, int
        *err = -E_GC_HELP_GIVEN;
        if (gc->conf->help_given)
                goto err_out;
+       *err = -E_GC_VERSION_GIVEN;
+       if (gc->conf->version_given)
+               goto err_out;
        *err = check_gc_args(gc);
        if (*err < 0)
                goto err_out;