tools api: Avoid potential double free
authorIan Rogers <irogers@google.com>
Mon, 9 Oct 2023 18:39:17 +0000 (11:39 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 12 Oct 2023 17:01:57 +0000 (10:01 -0700)
commitc4b5140c6eac2f757d9706c6c783b60554c48cb7
treec4020b92d38b6393b1e4e7666cd322b719d197cc
parent7875c72c8b0566590c888a2420d7e8fc12f67154
tools api: Avoid potential double free

io__getline will free the line on error but it doesn't clear the out
argument. This may lead to the line being freed twice, like in
tools/perf/util/srcline.c as detected by clang-tidy.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: llvm@lists.linux.dev
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Tom Rix <trix@redhat.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20231009183920.200859-17-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/lib/api/io.h