[openwrt/openwrt] ucode-mod-uline: fix refcounting errors

LEDE Commits lede-commits at lists.infradead.org
Tue Mar 4 23:25:49 PST 2025


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/12298ca7c497d497564ee22851e6fc2342f0f26e

commit 12298ca7c497d497564ee22851e6fc2342f0f26e
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Wed Mar 5 08:13:23 2025 +0100

    ucode-mod-uline: fix refcounting errors
    
    Do not call ucv_get if the reference is transferred without being used
    elsewhere
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 package/utils/ucode-mod-uline/src/ucode.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/package/utils/ucode-mod-uline/src/ucode.c b/package/utils/ucode-mod-uline/src/ucode.c
index 7f1d9b1e34..4f1a3b627c 100644
--- a/package/utils/ucode-mod-uline/src/ucode.c
+++ b/package/utils/ucode-mod-uline/src/ucode.c
@@ -153,8 +153,7 @@ uc_uline_get_line(uc_vm_t *vm, size_t nargs)
 		uline_get_line2(&us->s, &line, &len);
 	else
 		uline_get_line(&us->s, &line, &len);
-	val = ucv_string_new_length(line, len);
-	ucv_object_add(state, "line", ucv_get(val));
+	ucv_object_add(state, "line", ucv_string_new_length(line, len));
 	ucv_object_add(state, "pos", ucv_int64_new(us->s.line.pos));
 
 	return state;
@@ -589,7 +588,7 @@ uc_uline_add_pos(uc_vm_t *vm, uc_value_t *list, ssize_t start, ssize_t end)
 	uc_value_t *val = ucv_array_new(vm);
 	ucv_array_push(val, ucv_int64_new(start));
 	ucv_array_push(val, ucv_int64_new(end));
-	ucv_array_push(list, ucv_get(val));
+	ucv_array_push(list, val);
 }
 
 static uc_value_t *
@@ -630,8 +629,8 @@ uc_uline_parse_args(uc_vm_t *vm, size_t nargs, bool check)
 		if (argp->line_sep) {
 			args = ucv_array_new(vm);
 			pos_args = ucv_array_new(vm);
-			ucv_array_push(args, ucv_get(list));
-			ucv_array_push(pos_args, ucv_get(pos_list));
+			ucv_array_push(args, list);
+			ucv_array_push(pos_args, pos_list);
 		} else {
 			args = list;
 			pos_args = pos_list;
@@ -692,10 +691,10 @@ uc_uline_parse_args(uc_vm_t *vm, size_t nargs, bool check)
 
 						buf = NULL;
 						list = ucv_array_new(vm);
-						ucv_array_push(args, ucv_get(list));
+						ucv_array_push(args, list);
 
 						pos_list = ucv_array_new(vm);
-						ucv_array_push(pos_args, ucv_get(pos_list));
+						ucv_array_push(pos_args, pos_list);
 					}
 				}
 				continue;
@@ -751,7 +750,7 @@ uc_uline_parse_args(uc_vm_t *vm, size_t nargs, bool check)
 	}
 
 	if (buf) {
-		ucv_array_push(list, ucv_get(ucv_stringbuf_finish(buf)));
+		ucv_array_push(list, ucv_stringbuf_finish(buf));
 		uc_uline_add_pos(vm, pos_list, start_idx, end_idx);
 	}
 
@@ -762,10 +761,10 @@ uc_uline_parse_args(uc_vm_t *vm, size_t nargs, bool check)
 		return missing;
 
 	ret = ucv_object_new(vm);
-	ucv_object_add(ret, "args", ucv_get(args));
-	ucv_object_add(ret, "pos", ucv_get(pos_args));
+	ucv_object_add(ret, "args", args);
+	ucv_object_add(ret, "pos", pos_args);
 	if (missing)
-		ucv_object_add(ret, "missing", ucv_get(missing));
+		ucv_object_add(ret, "missing", missing);
 
 	return ret;
 }




More information about the lede-commits mailing list