Fix: lttng-elf.c: dereferencing pointer before null check
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 9 Oct 2019 13:32:40 +0000 (09:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 9 Oct 2019 15:46:05 +0000 (11:46 -0400)
Coverity report:
  CID 1405899 (#1 of 1): Dereference before null check (REVERSE_INULL)
  check_after_deref: Null-checking elf suggests that it may be null, but it has
  already been dereferenced on all paths leading to the check.

Reported-by: Coverity (1405899) Dereference before null check
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/lttng-elf.c

index 91afcfdea3d19ae0435d655e4b49465064832d07..63e658177c67f9aee422830d055c9b7987544a1e 100644 (file)
@@ -646,13 +646,14 @@ char *lttng_elf_get_section_data(struct lttng_elf *elf,
        int ret;
        off_t section_offset;
        char *data;
-       const size_t max_alloc_size = min_t(size_t, MAX_SECTION_DATA_SIZE,
-                       elf->file_size);
+       size_t max_alloc_size;
 
        if (!elf || !shdr) {
                goto error;
        }
 
+       max_alloc_size = min_t(size_t, MAX_SECTION_DATA_SIZE, elf->file_size);
+
        section_offset = shdr->sh_offset;
        if (lseek(elf->fd, section_offset, SEEK_SET) < 0) {
                PERROR("Error seeking to section offset");
This page took 0.029052 seconds and 4 git commands to generate.