diff options
author | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2017-03-19 11:24:16 +0100 |
---|---|---|
committer | Hanspeter Portner <dev@open-music-kontrollers.ch> | 2017-03-19 11:24:16 +0100 |
commit | a9ee41bb3eb9d7a9021c4213c50cd1bed09c32c7 (patch) | |
tree | 7f251cc05622d88fb5460c577cd0e9d3bcf4e646 /sherlock_nk.c | |
parent | 4caf28f553347a91867365dfa572f917ca06d230 (diff) | |
download | sherlock.lv2-a9ee41bb3eb9d7a9021c4213c50cd1bed09c32c7.tar.xz |
nk: add some checks.
Diffstat (limited to 'sherlock_nk.c')
-rw-r--r-- | sherlock_nk.c | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/sherlock_nk.c b/sherlock_nk.c index 5cc94f0..a8338ab 100644 --- a/sherlock_nk.c +++ b/sherlock_nk.c @@ -426,8 +426,48 @@ port_event(LV2UI_Handle instance, uint32_t i, uint32_t size, uint32_t urid, } case 2: { + const LV2_Atom_Tuple *tup = buf; + if(tup->atom.type != handle->forge.Tuple) + { + break; + } + + const LV2_Atom_Long *offset = NULL; + const LV2_Atom_Int *nsamples = NULL; + const LV2_Atom_Sequence *seq = NULL; + + unsigned k = 0; + LV2_ATOM_TUPLE_FOREACH(tup, item) + { + switch(k) + { + case 0: + { + if(item->type == handle->forge.Long) + offset = (const LV2_Atom_Long *)item; + } break; + case 1: + { + if(item->type == handle->forge.Int) + nsamples = (const LV2_Atom_Int *)item; + } break; + case 2: + { + if(item->type == handle->forge.Sequence) + seq = (const LV2_Atom_Sequence *)item; + } break; + } + + k++; + } + const bool overflow = handle->n_item > MAX_LINES; + if(!offset || !nsamples || !seq) + { + break; + } + if(overflow && handle->state.overwrite) { _clear(handle); @@ -438,12 +478,6 @@ port_event(LV2UI_Handle instance, uint32_t i, uint32_t size, uint32_t urid, break; } - const LV2_Atom *atom = buf; - const LV2_Atom_Tuple *tup = (const LV2_Atom_Tuple *)atom; - const LV2_Atom_Long *offset = (const LV2_Atom_Long *)lv2_atom_tuple_begin(tup); - const LV2_Atom_Int *nsamples = (const LV2_Atom_Int *)lv2_atom_tuple_next(&offset->atom); - const LV2_Atom_Sequence *seq = (const LV2_Atom_Sequence *)lv2_atom_tuple_next(&nsamples->atom); - // append frame { item_t *itm = _append_item(handle, ITEM_TYPE_FRAME, 0); |