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@nbd.name>
This commit is contained in:
Felix Fietkau 2025-03-05 08:13:23 +01:00
parent d65d546bce
commit 12298ca7c4

View File

@ -153,8 +153,7 @@ uc_uline_get_line(uc_vm_t *vm, size_t nargs)
uline_get_line2(&us->s, &line, &len); uline_get_line2(&us->s, &line, &len);
else else
uline_get_line(&us->s, &line, &len); uline_get_line(&us->s, &line, &len);
val = ucv_string_new_length(line, len); ucv_object_add(state, "line", ucv_string_new_length(line, len));
ucv_object_add(state, "line", ucv_get(val));
ucv_object_add(state, "pos", ucv_int64_new(us->s.line.pos)); ucv_object_add(state, "pos", ucv_int64_new(us->s.line.pos));
return state; 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); uc_value_t *val = ucv_array_new(vm);
ucv_array_push(val, ucv_int64_new(start)); ucv_array_push(val, ucv_int64_new(start));
ucv_array_push(val, ucv_int64_new(end)); ucv_array_push(val, ucv_int64_new(end));
ucv_array_push(list, ucv_get(val)); ucv_array_push(list, val);
} }
static uc_value_t * 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) { if (argp->line_sep) {
args = ucv_array_new(vm); args = ucv_array_new(vm);
pos_args = ucv_array_new(vm); pos_args = ucv_array_new(vm);
ucv_array_push(args, ucv_get(list)); ucv_array_push(args, list);
ucv_array_push(pos_args, ucv_get(pos_list)); ucv_array_push(pos_args, pos_list);
} else { } else {
args = list; args = list;
pos_args = pos_list; pos_args = pos_list;
@ -692,10 +691,10 @@ uc_uline_parse_args(uc_vm_t *vm, size_t nargs, bool check)
buf = NULL; buf = NULL;
list = ucv_array_new(vm); list = ucv_array_new(vm);
ucv_array_push(args, ucv_get(list)); ucv_array_push(args, list);
pos_list = ucv_array_new(vm); pos_list = ucv_array_new(vm);
ucv_array_push(pos_args, ucv_get(pos_list)); ucv_array_push(pos_args, pos_list);
} }
} }
continue; continue;
@ -751,7 +750,7 @@ uc_uline_parse_args(uc_vm_t *vm, size_t nargs, bool check)
} }
if (buf) { 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); 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; return missing;
ret = ucv_object_new(vm); ret = ucv_object_new(vm);
ucv_object_add(ret, "args", ucv_get(args)); ucv_object_add(ret, "args", args);
ucv_object_add(ret, "pos", ucv_get(pos_args)); ucv_object_add(ret, "pos", pos_args);
if (missing) if (missing)
ucv_object_add(ret, "missing", ucv_get(missing)); ucv_object_add(ret, "missing", missing);
return ret; return ret;
} }