diff --git a/src/topology/parser.c b/src/topology/parser.c index e70173f6..01c95afa 100644 --- a/src/topology/parser.c +++ b/src/topology/parser.c @@ -21,6 +21,25 @@ #include "list.h" #include "tplg_local.h" +/* + * Safe strtol call + */ +int safe_strtol_base(const char *str, long *val, int base) +{ + char *end; + long v; + if (!*str) + return -EINVAL; + errno = 0; + v = strtol(str, &end, base); + if (errno) + return -errno; + if (*end) + return -EINVAL; + *val = v; + return 0; +} + /* * Get integer value */