akgl_registry_load_properties leaks one string-pool slot per failed property #46

Open
opened 2026-08-02 18:33:31 -04:00 by tachikoma · 0 comments
Collaborator

Source: TODO.md, "Found while writing the manual" -> "Defects with no prior entry", item 11 (at bbb7b8f)

json_object_foreach(props, pkey, pvalue) {
    ATTEMPT {
        CATCH(errctx, akgl_heap_next_string(&tmpstr));
        CATCH(errctx, akgl_get_json_string_value(props, (char *)pkey, &tmpstr));
        SDL_SetStringProperty(AKGL_REGISTRY_PROPERTIES, pkey, tmpstr->data);
        SDL_Log("Set property %s = %s", pkey, tmpstr->data);
        CATCH(errctx, akgl_heap_release_string(tmpstr));
    } CLEANUP {
    } PROCESS(errctx) {
    } FINISH(errctx, true);
}

The release is the last statement inside the ATTEMPT block and the
per-property CLEANUP block is empty
, so any property whose value is the wrong
type breaks out before the release and the slot is never given back.

The string pool is 256 slots, so a sufficiently malformed properties file drains
it -- and once it is drained, every later claim anywhere in the process fails.

Fix: move the release into the CLEANUP block, which is what that block is
for.

Files: src/registry.c:175-185


Filed by Tachikoma (Claude Code, Opus 5, 1M context)

**Source:** TODO.md, "Found while writing the manual" -> "Defects with no prior entry", item 11 (at bbb7b8f) ```c json_object_foreach(props, pkey, pvalue) { ATTEMPT { CATCH(errctx, akgl_heap_next_string(&tmpstr)); CATCH(errctx, akgl_get_json_string_value(props, (char *)pkey, &tmpstr)); SDL_SetStringProperty(AKGL_REGISTRY_PROPERTIES, pkey, tmpstr->data); SDL_Log("Set property %s = %s", pkey, tmpstr->data); CATCH(errctx, akgl_heap_release_string(tmpstr)); } CLEANUP { } PROCESS(errctx) { } FINISH(errctx, true); } ``` The release is the last statement inside the `ATTEMPT` block and **the per-property `CLEANUP` block is empty**, so any property whose value is the wrong type breaks out before the release and the slot is never given back. The string pool is 256 slots, so a sufficiently malformed properties file drains it -- and once it is drained, every later claim anywhere in the process fails. **Fix:** move the release into the `CLEANUP` block, which is what that block is for. **Files:** `src/registry.c:175-185` --- Filed by Tachikoma (Claude Code, Opus 5, 1M context)
tachikoma added this to the 0.9.x milestone 2026-08-02 18:33:31 -04:00
tachikoma added the defectblast-radius:medium labels 2026-08-02 18:33:31 -04:00
tachikoma added the status::grooming label 2026-08-02 18:49:21 -04:00
Sign in to join this conversation.