diff --git a/shared/option-parser.c b/shared/option-parser.c index 33355b8b..fb4a3424 100644 --- a/shared/option-parser.c +++ b/shared/option-parser.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "config-parser.h" @@ -40,11 +41,17 @@ handle_option(const struct weston_option *option, char *value) switch (option->type) { case WESTON_OPTION_INTEGER: + errno = 0; * (int32_t *) option->data = strtol(value, &p, 10); - return *value && !*p; + if (errno != 0 || p == value || *p != '\0') + return 0; + return 1; case WESTON_OPTION_UNSIGNED_INTEGER: + errno = 0; * (uint32_t *) option->data = strtoul(value, &p, 10); - return *value && !*p; + if (errno != 0 || p == value || *p != '\0') + return 0; + return 1; case WESTON_OPTION_STRING: * (char **) option->data = strdup(value); return 1;