mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-27 21:58:16 +01:00
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 6cb69a40c7
)
This commit is contained in:
parent
6859861998
commit
e0a591fb93
1 changed files with 6 additions and 0 deletions
|
@ -80,6 +80,12 @@ enum movement_unit parse_movement_unit(const char *unit) {
|
||||||
|
|
||||||
int parse_movement_amount(int argc, char **argv,
|
int parse_movement_amount(int argc, char **argv,
|
||||||
struct movement_amount *amount) {
|
struct movement_amount *amount) {
|
||||||
|
if (!sway_assert(argc > 0, "Expected args in parse_movement_amount")) {
|
||||||
|
amount->amount = 0;
|
||||||
|
amount->unit = MOVEMENT_UNIT_INVALID;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
char *err;
|
char *err;
|
||||||
amount->amount = (int)strtol(argv[0], &err, 10);
|
amount->amount = (int)strtol(argv[0], &err, 10);
|
||||||
if (*err) {
|
if (*err) {
|
||||||
|
|
Loading…
Reference in a new issue