riverctl patch: fix some if statements that were terribly written at 11pm and actually properly free some data on error

This commit is contained in:
Zuki Air 2025-07-29 11:31:34 +01:00
parent fc5925e7b6
commit fb576dd523

View File

@ -1,4 +1,4 @@
From 2a7a35b64d091bb85cff4180d48a510cf5a28522 Mon Sep 17 00:00:00 2001
From 2c699064c0d592e35a7316e546648b6f56cb6e9c Mon Sep 17 00:00:00 2001
From: Zuki Air <zukirust@gmail.com>
Date: Sun, 27 Jul 2025 11:30:32 +0100
Subject: [PATCH] river-ctl patch
@ -13,8 +13,8 @@ improve uint error handling
dwl.c | 20 +-
dwlctl.c | 132 +++++
protocols/river-control-unstable-v1.xml | 85 +++
river-control.h | 732 ++++++++++++++++++++++++
7 files changed, 1012 insertions(+), 16 deletions(-)
river-control.h | 744 ++++++++++++++++++++++++
7 files changed, 1024 insertions(+), 16 deletions(-)
create mode 100644 dwlctl.c
create mode 100644 protocols/river-control-unstable-v1.xml
create mode 100644 river-control.h
@ -448,10 +448,10 @@ index 0000000..aa5fc4d
+</protocol>
diff --git a/river-control.h b/river-control.h
new file mode 100644
index 0000000..9583607
index 0000000..07cd8fb
--- /dev/null
+++ b/river-control.h
@@ -0,0 +1,732 @@
@@ -0,0 +1,744 @@
+#include "river-control-unstable-v1-private-protocol.c"
+#include "river-control-unstable-v1-protocol.h"
+#ifdef KEYS_USED
@ -1054,9 +1054,15 @@ index 0000000..9583607
+ } else if (strcmp("down",argument)) {
+ arg->i = WLR_DIRECTION_DOWN;
+ } else {
+ if (ZRIVER_ARG_TYPE_KEY) {
+ if (args->type == ZRIVER_ARG_TYPE_KEY) {
+ free(args->p.kl->key);
+ free(args->p.kl);
+ } else if (args->type == ZRIVER_ARG_TYPE_FUNC) {
+ if (args->str_link != NULL) {
+ free_str_store(args->str_link);
+ free(args->str_link);
+ }
+ free(args->p.fa);
+ }
+ args->error = true;
+ args->error_msg = zriver_error_out_of_range;
@ -1064,12 +1070,18 @@ index 0000000..9583607
+ break;
+ case(FUNC_STR_ARG_TYPE_LAYOUT):
+ arg->ui = strtol(argument,NULL,10);
+ if (arg->ui < LENGTH(layouts)) {
+ if (arg->ui < (int)LENGTH(layouts)) {
+ arg->v = &layouts[arg->ui];
+ } else {
+ if (ZRIVER_ARG_TYPE_KEY) {
+ if (args->type == ZRIVER_ARG_TYPE_KEY) {
+ free(args->p.kl->key);
+ free(args->p.kl);
+ } else if (args->type == ZRIVER_ARG_TYPE_FUNC) {
+ if (args->str_link != NULL) {
+ free_str_store(args->str_link);
+ free(args->str_link);
+ }
+ free(args->p.fa);
+ }
+ args->error = true;
+ args->error_msg = zriver_error_out_of_range;