Add lazy evaluation, and introduce use-after-free
Some checks failed
CMake / ubuntu-latest - shared=OFF, pthread=OFF, posix=OFF (push) Failing after 11s
CMake / ubuntu-latest - shared=ON, pthread=OFF, posix=OFF (push) Failing after 12s
CMake / ubuntu-latest - shared=OFF, pthread=OFF, posix=ON (push) Failing after 11s
CMake / ubuntu-latest - shared=ON, pthread=OFF, posix=ON (push) Failing after 12s
CMake / ubuntu-latest - shared=OFF, pthread=ON, posix=ON (push) Failing after 10s
CMake / ubuntu-latest - shared=ON, pthread=ON, posix=ON (push) Failing after 10s

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-08-01 08:06:25 +03:00
parent 1d40c785f8
commit 4664ad3bfb
2 changed files with 82 additions and 78 deletions

View File

@@ -105,39 +105,40 @@ int main(int argc, char **argv)
}
dcfg_Value *cur = evaled;
for (size_t i = 0; i < n; i++) {
for (size_t i = 0; i < n; ++i) {
Token *t = &toks[i];
dcfg_Value *next = NULL;
if (t->type == T_FIELD) {
if (!dcfg_Value_get_object_field_ex(cur, t->v.field, &next, true)) {
fprintf(stderr, "no such field\n");
dcfg_destroy(evaled);
dcfg_destroy(root);
dcfg_destroy_instance(inst);
return 1;
fputs("no such field\n", stderr);
goto fail;
}
} else {
if (!dcfg_Value_get_array_item_ex(cur, t->v.index, &next, true)) {
fprintf(stderr, "index out of bounds\n");
dcfg_destroy(evaled);
dcfg_destroy(root);
dcfg_destroy_instance(inst);
return 1;
fputs("index out of bounds\n", stderr);
goto fail;
}
}
if (cur != evaled)
if (cur != evaled) {
dcfg_destroy(cur);
}
cur = next;
}
print_value(cur);
if (cur != evaled)
if (cur != evaled) {
dcfg_destroy(cur);
}
dcfg_destroy(evaled);
dcfg_destroy(root);
dcfg_destroy_instance(inst);
return 0;
fail:
dcfg_destroy(evaled);
dcfg_destroy(root);
dcfg_destroy_instance(inst);
return 1;
}