mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-30 07:10:08 +01:00
util: if errno is nonzero, exit early from safe_atoi
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
4a5dcbf69b
commit
13428f5d82
1 changed files with 4 additions and 0 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue