mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-27 23:10:07 +01:00
util: if errno is nonzero, exit early from safe_atoi
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 13428f5d82)
This commit is contained in:
parent
59d1ed9466
commit
690dd44121
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