diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2016-11-24 10:48:39 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2016-12-06 17:39:03 +1000 |
commit | 690dd44121e22b14085cae98eb965ac53ca2f2db (patch) | |
tree | 37244fac641df45fbeae8796a129d02adf15ba3d /src | |
parent | 59d1ed9466c7902bf1ae452091a43f3254620c2e (diff) |
util: if errno is nonzero, exit early from safe_atoi
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 13428f5d82a25c1f56fa247d4a201f805d80fde6)
Diffstat (limited to 'src')
-rw-r--r-- | src/libinput-util.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libinput-util.h b/src/libinput-util.h index 6c9afdc1..a42643d3 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -28,6 +28,7 @@ #include "config.h" #include <assert.h> +#include <errno.h> #include <limits.h> #include <math.h> #include <stdarg.h> @@ -410,7 +411,10 @@ safe_atoi(const char *str, int *val) char *endptr; long v; + errno = 0; v = strtol(str, &endptr, 10); + if (errno > 0) + return false; if (str == endptr) return false; if (*str != '\0' && *endptr != '\0') |