Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode: fix possible NULL dereference #189

Merged
merged 3 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/cmt_decode_msgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,11 @@ static int unpack_basic_type_meta(mpack_reader_t *reader, size_t index, void *co
result = cmt_mpack_unpack_map(reader, callbacks, context);

if (CMT_DECODE_MSGPACK_SUCCESS == result) {
decode_context->map->label_count = cfl_list_size(&decode_context->map->label_keys);
if (decode_context->map == NULL || decode_context->map->parent == NULL) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a chance that decode_context->map is NULL ideally we want do it before the previous line otherwise it leads to a corruption decode_context->map->...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return CMT_DECODE_MSGPACK_INVALID_ARGUMENT_ERROR;
}

decode_context->map->label_count = cfl_list_size(&decode_context->map->label_keys);
if (decode_context->map->type == CMT_HISTOGRAM) {
histogram = (struct cmt_histogram *) decode_context->map->parent;

Expand Down