This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/67540] New: string_intrinsics_inc.c sanitizer detects null pointer passed to memcpy
- From: "zeccav at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 10 Sep 2015 13:22:04 +0000
- Subject: [Bug libfortran/67540] New: string_intrinsics_inc.c sanitizer detects null pointer passed to memcpy
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67540
Bug ID: 67540
Summary: string_intrinsics_inc.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: ---
During make check-fortran in gcc build the sanitizer complains
that a null pointer is passed to memcpy in string_intrinsics_inc.c:89
res = MEMCMP (s1, s2, ((len1 < len2) ? len1 : len2));
string_intrinsics_inc.c:90:7: runtime error: null pointer passed as argument 1,
which is declared to never be null
because s1 == NULL
My fix is
int lvz=len1 < len2 ? len1 : len2;
if(lvz) res = MEMCMP (s1, s2, lvz); else res=0;