re PR libfortran/81984 (NULL string pointer dereferencing forces undefined behaviour in libgfortran)

2018-12-28  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/81984
	* intrinsics/string_intrinsics_inc.c: Placate the sanitizer.

From-SVN: r267452
This commit is contained in:
Steven G. Kargl 2018-12-28 18:26:09 +00:00
parent 691adeb097
commit 07b700ead5
2 changed files with 13 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2018-12-28 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/81984
* intrinsics/string_intrinsics_inc.c: Placate the sanitizer.
2018-12-21 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/69121

View File

@ -87,6 +87,14 @@ compare_string (gfc_charlen_type len1, const CHARTYPE *s1,
gfc_charlen_type len;
int res;
/* Placate the sanitizer. */
if (!s1 && !s2)
return 0;
if (!s1)
return -1;
if (!s2)
return 1;
res = MEMCMP (s1, s2, ((len1 < len2) ? len1 : len2));
if (res != 0)
return res;