diff options
author | David Robillard <d@drobilla.net> | 2024-12-11 19:08:06 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2024-12-11 19:39:22 -0500 |
commit | 8bd6f662b5cf5111985daad42b21b9da37ab6a44 (patch) | |
tree | ef00b3467bb1c8b8bbba006a6a7f72b390d6692f /src/state.c | |
parent | 35354abb37202f99bec2d65e437dd7e2f8ffbc9d (diff) | |
download | lilv-8bd6f662b5cf5111985daad42b21b9da37ab6a44.tar.gz lilv-8bd6f662b5cf5111985daad42b21b9da37ab6a44.tar.bz2 lilv-8bd6f662b5cf5111985daad42b21b9da37ab6a44.zip |
Avoid potential null dereferences and use of unterminated string
Diffstat (limited to 'src/state.c')
-rw-r--r-- | src/state.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/state.c b/src/state.c index 169ccbe..48d7230 100644 --- a/src/state.c +++ b/src/state.c @@ -669,12 +669,13 @@ new_state_from_model(LilvWorld* world, chunk.len = 0; sratom_read(sratom, &forge, world->world, model, value); const LV2_Atom* atom = (const LV2_Atom*)chunk.buf; - - append_port_value(state, - (const char*)sord_node_get_string(symbol), - LV2_ATOM_BODY_CONST(atom), - atom->size, - atom->type); + if (atom) { + append_port_value(state, + (const char*)sord_node_get_string(symbol), + LV2_ATOM_BODY_CONST(atom), + atom->size, + atom->type); + } if (label) { lilv_state_set_label(state, (const char*)sord_node_get_string(label)); @@ -704,6 +705,9 @@ new_state_from_model(LilvWorld* world, const LV2_Atom* atom = (const LV2_Atom*)chunk.buf; uint32_t flags = LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE; Property prop = {NULL, 0, 0, 0, flags}; + if (!atom) { + continue; + } prop.key = map->map(map->handle, key); prop.type = atom->type; |