[Bug libfortran/67536] New: unix.c sanitizer detects null pointer passed to memcpy

zeccav at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Sep 10 04:22:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67536

            Bug ID: 67536
           Summary: unix.c sanitizer detects null pointer passed to memcpy
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeccav at gmail dot com
  Target Milestone: ---

Running "make check" after building gcc the sanitizer complains that
at unix.c:497

memcpy (buf, s->buffer + (s->logical_offset - s->buffer_offset), nbyte);

the pointer buf == NULL

but nbyte == 0 so it should be harmless.
I believe that

if(nbyte) memcpy (buf, s->buffer + (s->logical_offset - s->buffer_offset),
nbyte);

should avoid this undefined behaviour.



More information about the Gcc-bugs mailing list