From: Jonathan Rajotte Date: Wed, 14 Nov 2018 19:38:37 +0000 (-0500) Subject: Fix: Initialize fd field of struct lttng_ust_elf to -1 at allocation X-Git-Tag: v2.12.0-rc1~59 X-Git-Url: http://git.lttng.org/?p=lttng-ust.git;a=commitdiff_plain;h=1ac2e79cfa9574fde7b3d09d4c6c2ec368185f7f Fix: Initialize fd field of struct lttng_ust_elf to -1 at allocation In rare cases when the executable cannot be open, using a default value of zero lead to invalid close call and fd tracker removal. fixes #1171 Reported-by: Stefan Palade Signed-off-by: Jonathan Rajotte Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-ust-elf.c b/liblttng-ust/lttng-ust-elf.c index c073e7a5..3d6a9379 100644 --- a/liblttng-ust/lttng-ust-elf.c +++ b/liblttng-ust/lttng-ust-elf.c @@ -250,6 +250,8 @@ struct lttng_ust_elf *lttng_ust_elf_create(const char *path) goto error; } + /* Initialize fd field to -1. 0 is a valid fd number */ + elf->fd = -1; elf->path = strdup(path); if (!elf->path) {