diff --git a/src/scanner.c b/src/scanner.c index 809130b1..b6b8d250 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -404,11 +404,13 @@ start_element(void *data, const char *element_name, const char **atts) message->destructor = 0; if (since != NULL) { + int prev_errno = errno; errno = 0; version = strtol(since, &end, 0); - if (errno == EINVAL || end == since || *end != '\0') + if (errno != 0 || end == since || *end != '\0') fail(&ctx->loc, "invalid integer (%s)\n", since); + errno = prev_errno; } else { version = 1; } diff --git a/src/wayland-client.c b/src/wayland-client.c index b0f77b9e..01629e01 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -829,9 +829,12 @@ wl_display_connect(const char *name) connection = getenv("WAYLAND_SOCKET"); if (connection) { + int prev_errno = errno; + errno = 0; fd = strtol(connection, &end, 0); - if (*end != '\0') + if (errno != 0 || connection == end || *end != '\0') return NULL; + errno = prev_errno; flags = fcntl(fd, F_GETFD); if (flags != -1)