Fix: `ctf` plugin: do not have an `mdec` variable where not strictly needed
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 20 Jun 2019 19:54:48 +0000 (15:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:32 +0000 (11:53 -0400)
commita248254b26128ff8a104bdb4455f5b2d2ea00323
tree93caa1bce13a18df39c40e55be29edac92856063
parent32d2d479b457ba07d60c09928362a44f0bc2762c
Fix: `ctf` plugin: do not have an `mdec` variable where not strictly needed

Issue
=====
The `metadata-info` query needs to call
ctf_metadata_decoder_packetized_file_stream_to_buf() with a custom log
level and no self component (`NULL`). Eventually, this reaches
decode_packet() which is in the `decoder.c` file and thus uses
`mdec->self_comp` to find its self component in the BT_COMP_LOG*()
macros. But in this case, `mdec` is `NULL`, so there's an invalid
memory access.

Solution
========
Instead of using BT_COMP_LOG_CUR_LVL() everywhere in this function, and
because decode_packet() and
ctf_metadata_decoder_packetized_file_stream_to_buf_with_mdec() do not
strictly need `mdec` except for logging its address at some places, move
the functions to the new `decoder-packetized-file-stream-to-buf.c` file
and make them not accept an `mdec` argument.

This new file's logging uses the local `log_level` and `self_comp`
variables, so the logging statement are not modified.

Known drawbacks
===============
None.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I55874790b2b873ff1718a774e57011300e57518d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1526
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/common/metadata/Makefile.am
src/plugins/ctf/common/metadata/decoder-packetized-file-stream-to-buf.c [new file with mode: 0644]
src/plugins/ctf/common/metadata/decoder.c
src/plugins/ctf/common/metadata/decoder.h
src/plugins/ctf/fs-src/query.c
This page took 0.026065 seconds and 4 git commands to generate.