aboutsummaryrefslogtreecommitdiff
path: root/swaynag
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-06-05 18:26:12 +0200
committerBrian Ashworth <bosrsf04@gmail.com>2019-06-05 14:40:29 -0400
commitb4b274cdcea5269fc39ef9c846157d211f79eec9 (patch)
treebc58e4b6615053bdabececbb959b595d011e520d /swaynag
parent900d3287f9b63df6320fa159aa0a842e8e8afd3d (diff)
check for empty string before calling strtoul() and check errno
Note: since strtoul() has no real error return code (both 0 and ULONG_MAX may be returned on both success and failure), set errno=0 before calling strtoul().
Diffstat (limited to 'swaynag')
-rw-r--r--swaynag/swaynag.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/swaynag/swaynag.c b/swaynag/swaynag.c
index 87199a74..caa10ccd 100644
--- a/swaynag/swaynag.c
+++ b/swaynag/swaynag.c
@@ -132,10 +132,11 @@ static void update_cursor(struct swaynag *swaynag) {
const char *cursor_theme = getenv("XCURSOR_THEME");
unsigned cursor_size = 24;
const char *env_cursor_size = getenv("XCURSOR_SIZE");
- if (env_cursor_size) {
+ if (env_cursor_size && strlen(env_cursor_size) > 0) {
+ errno = 0;
char *end;
unsigned size = strtoul(env_cursor_size, &end, 10);
- if (!*end) {
+ if (!*end && errno == 0) {
cursor_size = size;
}
}