From cdc0e316aa1f2105d8a56f57f7e8a34acbb42296 Mon Sep 17 00:00:00 2001 From: David Korczynski Date: Fri, 20 Oct 2023 16:28:46 +0100 Subject: [PATCH] encode_msgpack: Fix null-dereference Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=62368 Signed-off-by: David Korczynski --- src/ctr_encode_msgpack.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ctr_encode_msgpack.c b/src/ctr_encode_msgpack.c index bd3d187..5f4b51c 100644 --- a/src/ctr_encode_msgpack.c +++ b/src/ctr_encode_msgpack.c @@ -418,7 +418,12 @@ static void pack_scope_spans(mpack_writer_t *writer, struct cfl_list *scope_span /* scope */ mpack_write_cstr(writer, "scope"); - pack_instrumentation_scope(writer, scope_span->instrumentation_scope); + if (scope_span->instrumentation_scope != NULL) { + pack_instrumentation_scope(writer, scope_span->instrumentation_scope); + } + else { + mpack_write_nil(writer); + } /* spans */ mpack_write_cstr(writer, "spans");