re PR libfortran/81984 (NULL string pointer dereferencing forces undefined behaviour...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 28 Dec 2018 18:26:09 +0000 (18:26 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Fri, 28 Dec 2018 18:26:09 +0000 (18:26 +0000)
2018-12-28  Steven G. Kargl  <kargl@gcc.gnu.org>

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

From-SVN: r267452

libgfortran/ChangeLog
libgfortran/intrinsics/string_intrinsics_inc.c

index 03efb11..8397eee 100644 (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
index bfec683..b81c806 100644 (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;