From: Steven G. Kargl Date: Fri, 28 Dec 2018 18:26:09 +0000 (+0000) Subject: re PR libfortran/81984 (NULL string pointer dereferencing forces undefined behaviour... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=07b700ead5362478da6686c28d30fe4ffac2b6bd;p=gcc.git re PR libfortran/81984 (NULL string pointer dereferencing forces undefined behaviour in libgfortran) 2018-12-28 Steven G. Kargl PR fortran/81984 * intrinsics/string_intrinsics_inc.c: Placate the sanitizer. From-SVN: r267452 --- diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 03efb11a29d..8397eee6607 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2018-12-28 Steven G. Kargl + + PR fortran/81984 + * intrinsics/string_intrinsics_inc.c: Placate the sanitizer. + 2018-12-21 Steven G. Kargl PR fortran/69121 diff --git a/libgfortran/intrinsics/string_intrinsics_inc.c b/libgfortran/intrinsics/string_intrinsics_inc.c index bfec683f528..b81c806db5d 100644 --- a/libgfortran/intrinsics/string_intrinsics_inc.c +++ b/libgfortran/intrinsics/string_intrinsics_inc.c @@ -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;