[GRASS-git] [OSGeo/grass] 917ba5: r.out.png: fix consecutive fclose calls on same po...

ymdatta noreply at github.com
Fri Aug 23 04:56:28 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: 917ba5890cf34cef9dcbf1477339c1b0caaaaf24
      https://github.com/OSGeo/grass/commit/917ba5890cf34cef9dcbf1477339c1b0caaaaf24
  Author: ymdatta <ymdatta.work at gmail.com>
  Date:   2024-08-23 (Fri, 23 Aug 2024)

  Changed paths:
    M raster/r.out.png/main.c

  Log Message:
  -----------
  r.out.png: fix consecutive fclose calls on same pointer (#4214)

This patch fixes two issues:

1. In one of the code paths, we are calling fclose on a
   file pointer which could potentially be NULL. Doing that
   would lead to undefined behavior. Check if a file pointer
   is NULL before closing it.

2. If we call fclose on same file pointer twice, in the
   second instance we could be closing file descriptor allocated
   to some other file, which typically happens to a freed
   descriptor.

This issue was found by using cppcheck tool.

Signed-off-by: Mohana Datta Yelugoti <ymdatta.work at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications


More information about the grass-commit mailing list