bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fix memleak in getdelim.m4


From: Bruno Haible
Subject: Re: Fix memleak in getdelim.m4
Date: Thu, 21 May 2020 20:40:09 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-177-generic; KDE/5.18.0; x86_64; ; )

Tim Rühsen wrote:
> configure:36833: checking whether memmem works
> SUMMARY: UndefinedBehaviorSanitizer: invalid-null-argument

This patch should fix it.


2020-05-21  Bruno Haible  <address@hidden>

        memmem: Avoid wrong configure results with "clang -fsanitize=undefined".
        Reported by Tim Rühsen in
        <https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00207.html>.
        * m4/memmem.m4 (gl_FUNC_MEMMEM_SIMPLE): Use NULL + 1, not NULL.

diff --git a/m4/memmem.m4 b/m4/memmem.m4
index e034d7b..35a5bb1 100644
--- a/m4/memmem.m4
+++ b/m4/memmem.m4
@@ -1,4 +1,4 @@
-# memmem.m4 serial 26
+# memmem.m4 serial 27
 dnl Copyright (C) 2002-2004, 2007-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -37,7 +37,7 @@ AC_DEFUN([gl_FUNC_MEMMEM_SIMPLE],
     /* Check for empty needle behavior.  */
     {
       const char *haystack = "AAA";
-      if (memmem (haystack, 3, NULL, 0) != haystack)
+      if (memmem (haystack, 3, (const char *) 1, 0) != haystack)
         result |= 2;
     }
     return result;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]