I am looking at src/deliver.c lines 1543-1562:

      {
      uschar * s;
      FILE * f = Ufopen(addr->return_filename, "rb");
      if (!f)
        log_write(0, LOG_MAIN|LOG_PANIC, "failed to open %s to log output "
          "from %s transport: %s", addr->return_filename, tb->drinst.name,
          strerror(errno));
      else
        if ((s = US Ufgets(big_buffer, big_buffer_size, f)))
          {
          uschar *p = big_buffer + Ustrlen(big_buffer);
          const uschar * sp;
          while (p > big_buffer && isspace(p[-1])) p--;
          *p = 0;
          sp = string_printing(big_buffer);
          log_write(0, LOG_MAIN, "<%s>: %s transport output: %s",
            addr->address, tb->drinst.name, sp);
          }
      (void)fclose(f);
      }

cppcheck reports:
deliver.c:1561:20: warning: Either the condition '!f' is redundant or there is possible null pointer dereference: f. [nullPoin
terRedundantCheck]
      (void)fclose(f);
                   ^
deliver.c:1546:11: note: Assuming that condition '!f' is not redundant
      if (!f)
          ^
deliver.c:1561:20: note: Null pointer dereference
      (void)fclose(f);

Now log_write(0, LOG_MAIN|LOG_PANIC_DIE, ...)
- note the _DIE - does not return, but am I right in thinking that
 log_write(LOG_PANIC ...) *does* return so cppcheck is correct
and we do attempt to close a filehandle that we failed to open ?

--
Andrew C. Aitchison                      Kendal, UK
                   and...@aitchison.me.uk

--
## subscription configuration (requires account):
##   https://lists.exim.org/mailman3/postorius/lists/exim-dev.lists.exim.org/
## unsubscribe (doesn't require an account):
##   exim-dev-unsubscr...@lists.exim.org
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to