Fix: avoid double-free in build_index_from_idx_file
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 16 Oct 2019 20:45:22 +0000 (16:45 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 17 Oct 2019 18:46:10 +0000 (14:46 -0400)
commitf35a48bc5c6a73d05cc441bc34d4371e27265679
treed6f9027105d4968dc7703b1698ba27023120c594
parenta8bd1d0f5fc13e33d461e4f0bc1575a8e1f4d45b
Fix: avoid double-free in build_index_from_idx_file

If the validation at the end of build_index_from_idx_file fails, the
index_entry variable will still point to the last processed index entry.
That same entry will also have been added to the index->entries array.

In the error path, we free index_entry and the index object, which frees
that index entry twice.

Fix it by clearing index_entry after adding the entry to the index
object (the ownership is conceptually transferred).

I don't add a test with this patch, because the file that triggers this
bug now hits a bug further in the processing.  That file will be added
in the testsuite when it will no longer make babeltrace crash.

Change-Id: I091785895541105273c5d07d49f35628c2682e30
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2211
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/fs-src/data-stream-file.c
This page took 0.024358 seconds and 4 git commands to generate.