diff options
author | Simon Ser <contact@emersion.fr> | 2022-01-09 01:03:49 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-01-16 19:26:57 +0100 |
commit | e0a591fb93a17e0a0f6ee8a8a285392d04a02c01 (patch) | |
tree | c705a62c29a042d06270874f82610d743384345c | |
parent | build: bump version to 1.7-rc2 (diff) | |
download | sway-e0a591fb93a17e0a0f6ee8a8a285392d04a02c01.tar.gz sway-e0a591fb93a17e0a0f6ee8a8a285392d04a02c01.tar.zst sway-e0a591fb93a17e0a0f6ee8a8a285392d04a02c01.zip |
Add safety assert in parse_movement_unit
Let's add this just in case a caller passes argc == 0.
References: https://github.com/swaywm/sway/issues/6737#issuecomment-1008082540
(cherry picked from commit 6cb69a40c757cc44906fd928c43e60612c0e7ce8)
-rw-r--r-- | common/util.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index 199f3ee1..5d4c0673 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -80,6 +80,12 @@ enum movement_unit parse_movement_unit(const char *unit) { | |||
80 | 80 | ||
81 | int parse_movement_amount(int argc, char **argv, | 81 | int parse_movement_amount(int argc, char **argv, |
82 | struct movement_amount *amount) { | 82 | struct movement_amount *amount) { |
83 | if (!sway_assert(argc > 0, "Expected args in parse_movement_amount")) { | ||
84 | amount->amount = 0; | ||
85 | amount->unit = MOVEMENT_UNIT_INVALID; | ||
86 | return 0; | ||
87 | } | ||
88 | |||
83 | char *err; | 89 | char *err; |
84 | amount->amount = (int)strtol(argv[0], &err, 10); | 90 | amount->amount = (int)strtol(argv[0], &err, 10); |
85 | if (*err) { | 91 | if (*err) { |