From 4c45e28e8ae8f6228d9ccf8c5298ad6835dc8354 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Thu, 29 Jan 2015 13:24:12 +0100 Subject: [PATCH] Cleanup of e->typedefs. Added check that types are registered before encoding them. --- lib/c/2014/labcomm_encoder.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/c/2014/labcomm_encoder.c b/lib/c/2014/labcomm_encoder.c index 4f81294..44ecb77 100644 --- a/lib/c/2014/labcomm_encoder.c +++ b/lib/c/2014/labcomm_encoder.c @@ -98,6 +98,7 @@ void labcomm_encoder_free(struct labcomm_encoder* e) labcomm_writer_free(e->writer, e->writer->action_context); LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, e->registered, int); LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, e->sample_ref, int); + LABCOMM_SIGNATURE_ARRAY_FREE(e->memory, e->typedefs, int); labcomm_memory_free(memory, 0, e); } //================ @@ -407,6 +408,10 @@ int labcomm_internal_encode( index = labcomm_get_local_index(signature); length = (signature->encoded_size(value)); labcomm_scheduler_writer_lock(e->scheduler); + if (! LABCOMM_SIGNATURE_ARRAY_GET(e->registered, int, index, 0)) { + result = -EINVAL; + goto no_end; + } result = labcomm_writer_start(e->writer, e->writer->action_context, index, signature, value); if (result == -EALREADY) { result = 0; goto no_end; } -- GitLab