diff mbox series

PR fortran/81984 -- Placate the sanitizer

Message ID 20181226044228.GA988@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/81984 -- Placate the sanitizer | expand

Commit Message

Steve Kargl Dec. 26, 2018, 4:42 a.m. UTC
Tested on i586-*-freebsd.  OK to commit?

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

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

Patch

Index: libgfortran/intrinsics/string_intrinsics_inc.c
===================================================================
--- libgfortran/intrinsics/string_intrinsics_inc.c	(revision 267418)
+++ libgfortran/intrinsics/string_intrinsics_inc.c	(working copy)
@@ -87,6 +87,14 @@  compare_string (gfc_charlen_type len1, const CHARTYPE 
   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;