This completes the work done on 2016-02-06 on this topic.
* m4/memmem.m4 (gl_FUNC_MEMMEM): Free allocated memory before returning.
* m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): Likewise.
* m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
* m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
* m4/fopen.m4 (gl_FUNC_FOPEN): Close allocated FILE streams before
returning.
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise.
* m4/fpurge.m4 (gl_FUNC_FPURGE): Likewise.
* m4/ftello.m4 (gl_FUNC_FTELLO): Likewise.
* m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
* m4/signbit.m4 (gl_FLOATTYPE_SIGN_LOCATION): Likewise.
* m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Likewise.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Close allocated FILE streams and
free allocated memory before returning.
* m4/getline.m4 (gl_FUNC_GETLINE): Likewise.
* m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Close allocated DIR
objects before returning.
* m4/iconv.m4 (AM_ICONV_LINK): Close allocated iconv_t handles before
returning.
+2017-05-20 Bruno Haible <bruno@clisp.org>
+
+ Avoid wrong configure results with gcc -fsanitize=address.
+ This completes the work done on 2016-02-06 on this topic.
+ * m4/memmem.m4 (gl_FUNC_MEMMEM): Free allocated memory before returning.
+ * m4/getcwd.m4 (gl_FUNC_GETCWD_NULL): Likewise.
+ * m4/strcasestr.m4 (gl_FUNC_STRCASESTR): Likewise.
+ * m4/strstr.m4 (gl_FUNC_STRSTR): Likewise.
+ * m4/fopen.m4 (gl_FUNC_FOPEN): Close allocated FILE streams before
+ returning.
+ * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Likewise.
+ * m4/fpurge.m4 (gl_FUNC_FPURGE): Likewise.
+ * m4/ftello.m4 (gl_FUNC_FTELLO): Likewise.
+ * m4/rmdir-errno.m4 (gl_FUNC_RMDIR_NOTEMPTY): Likewise.
+ * m4/signbit.m4 (gl_FLOATTYPE_SIGN_LOCATION): Likewise.
+ * m4/ungetc.m4 (gl_FUNC_UNGETC_WORKS): Likewise.
+ * m4/getdelim.m4 (gl_FUNC_GETDELIM): Close allocated FILE streams and
+ free allocated memory before returning.
+ * m4/getline.m4 (gl_FUNC_GETLINE): Likewise.
+ * m4/d-ino.m4 (gl_CHECK_TYPE_STRUCT_DIRENT_D_INO): Close allocated DIR
+ objects before returning.
+ * m4/iconv.m4 (AM_ICONV_LINK): Close allocated iconv_t handles before
+ returning.
+
2017-05-20 Bruno Haible <bruno@clisp.org>
gnulib-tool: Don't create hard links between gnulib and its testdirs.
-# serial 15
+# serial 16
dnl From Jim Meyering.
dnl
return 1;
e = readdir (dp);
if (! e)
- return 2;
+ { closedir (dp); return 2; }
if (lstat (e->d_name, &st) != 0)
- return 3;
+ { closedir (dp); return 3; }
if (e->d_ino != st.st_ino)
- return 4;
+ { closedir (dp); return 4; }
closedir (dp);
return 0;
]])],
-# fflush.m4 serial 15
+# fflush.m4 serial 16
# Copyright (C) 2007-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
return 1;
fd = fileno (f);
if (fd < 0 || fread (buffer, 1, 5, f) != 5)
- return 2;
+ { fclose (f); return 2; }
/* For deterministic results, ensure f read a bigger buffer. */
if (lseek (fd, 0, SEEK_CUR) == 5)
- return 3;
+ { fclose (f); return 3; }
/* POSIX requires fflush-fseek to set file offset of fd. This fails
on BSD systems and on mingw. */
if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
- return 4;
+ { fclose (f); return 4; }
if (lseek (fd, 0, SEEK_CUR) != 5)
- return 5;
+ { fclose (f); return 5; }
/* Verify behaviour of fflush after ungetc. See
<http://www.opengroup.org/austin/aardvark/latest/xshbug3.txt> */
/* Verify behaviour of fflush after a backup ungetc. This fails on
ungetc (c, f);
fflush (f);
if (fgetc (f) != c)
- return 6;
+ { fclose (f); return 6; }
/* Verify behaviour of fflush after a non-backup ungetc. This fails
on glibc 2.8 and on BSD systems. */
c = fgetc (f);
ungetc ('@', f);
fflush (f);
if (fgetc (f) != c)
- return 7;
+ { fclose (f); return 7; }
+ fclose (f);
return 0;
]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
[gl_cv_func_fflush_stdin=cross])
-# fopen.m4 serial 9
+# fopen.m4 serial 10
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
#include <stdio.h>
int main ()
{
- return fopen ("conftest.sl/", "w") != NULL;
+ FILE *fp = fopen ("conftest.sl/", "w");
+ int result = (fp != NULL);
+ if (fp != NULL)
+ fclose (fp);
+ return result;
}]])],
[gl_cv_func_fopen_slash=yes],
[gl_cv_func_fopen_slash=no],
-# fpurge.m4 serial 7
+# fpurge.m4 serial 8
dnl Copyright (C) 2007, 2009-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
HAVE_FPURGE=1
# Detect BSD bug. Only cygwin 1.7 is known to be immune.
AC_CACHE_CHECK([whether fpurge works], [gl_cv_func_fpurge_works],
- [AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
-]], [FILE *f = fopen ("conftest.txt", "w+");
- if (!f) return 1;
- if (fputc ('a', f) != 'a') return 2;
- rewind (f);
- if (fgetc (f) != 'a') return 3;
- if (fgetc (f) != EOF) return 4;
- if (fpurge (f) != 0) return 5;
- if (putc ('b', f) != 'b') return 6;
- if (fclose (f) != 0) return 7;
- if ((f = fopen ("conftest.txt", "r")) == NULL) return 8;
- if (fgetc (f) != 'a') return 9;
- if (fgetc (f) != 'b') return 10;
- if (fgetc (f) != EOF) return 11;
- if (fclose (f) != 0) return 12;
- if (remove ("conftest.txt") != 0) return 13;
- return 0;])],
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <stdio.h>
+]],
+ [FILE *f = fopen ("conftest.txt", "w+");
+ if (!f)
+ return 1;
+ if (fputc ('a', f) != 'a')
+ { fclose (f); return 2; }
+ rewind (f);
+ if (fgetc (f) != 'a')
+ { fclose (f); return 3; }
+ if (fgetc (f) != EOF)
+ { fclose (f); return 4; }
+ if (fpurge (f) != 0)
+ { fclose (f); return 5; }
+ if (putc ('b', f) != 'b')
+ { fclose (f); return 6; }
+ if (fclose (f) != 0)
+ return 7;
+ if ((f = fopen ("conftest.txt", "r")) == NULL)
+ return 8;
+ if (fgetc (f) != 'a')
+ { fclose (f); return 9; }
+ if (fgetc (f) != 'b')
+ { fclose (f); return 10; }
+ if (fgetc (f) != EOF)
+ { fclose (f); return 11; }
+ if (fclose (f) != 0)
+ return 12;
+ if (remove ("conftest.txt") != 0)
+ return 13;
+ return 0;
+ ])],
[gl_cv_func_fpurge_works=yes], [gl_cv_func_fpurge_works=no],
[gl_cv_func_fpurge_works='guessing no'])])
if test "x$gl_cv_func_fpurge_works" != xyes; then
-# ftello.m4 serial 11
+# ftello.m4 serial 12
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if (fp == NULL)
return 70;
if (fwrite ("foogarsh", 1, 8, fp) < 8)
- return 71;
+ { fclose (fp); return 71; }
if (fclose (fp))
return 72;
if (fp == NULL)
return 73;
if (fseek (fp, -1, SEEK_END))
- return 74;
+ { fclose (fp); return 74; }
if (!(getc (fp) == 'h'))
- return 1;
+ { fclose (fp); return 1; }
if (!(getc (fp) == EOF))
- return 2;
+ { fclose (fp); return 2; }
if (!(ftell (fp) == 8))
- return 3;
+ { fclose (fp); return 3; }
if (!(ftell (fp) == 8))
- return 4;
+ { fclose (fp); return 4; }
if (!(putc ('!', fp) == '!'))
- return 5;
+ { fclose (fp); return 5; }
if (!(ftell (fp) == 9))
- return 6;
+ { fclose (fp); return 6; }
if (!(fclose (fp) == 0))
return 7;
fp = fopen (TESTFILE, "r");
{
char buf[10];
if (!(fread (buf, 1, 10, fp) == 9))
- return 10;
+ { fclose (fp); return 10; }
if (!(memcmp (buf, "foogarsh!", 9) == 0))
- return 11;
+ { fclose (fp); return 11; }
}
if (!(fclose (fp) == 0))
return 12;
# with or without modifications, as long as this notice is preserved.
# Written by Paul Eggert.
-# serial 13
+# serial 14
AC_DEFUN([gl_FUNC_GETCWD_NULL],
[
if (! f)
return 2;
if (f[0] != '/')
- return 3;
+ { free (f); return 3; }
if (f[1] != '\0')
- return 4;
+ { free (f); return 4; }
free (f);
return 0;
}
-# getdelim.m4 serial 11
+# getdelim.m4 serial 12
dnl Copyright (C) 2005-2007, 2009-2017 Free Software Foundation, Inc.
dnl
size_t siz = 0;
int len = getdelim (&line, &siz, '\n', in);
if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
- return 2;
+ { free (line); fclose (in); return 2; }
}
{
/* Test result for a NULL buffer and a non-zero size.
char *line = NULL;
size_t siz = (size_t)(~0) / 4;
if (getdelim (&line, &siz, '\n', in) == -1)
- return 3;
+ { fclose (in); return 3; }
free (line);
}
fclose (in);
-# getline.m4 serial 27
+# getline.m4 serial 28
dnl Copyright (C) 1998-2003, 2005-2007, 2009-2017 Free Software Foundation,
dnl Inc.
size_t siz = 0;
int len = getline (&line, &siz, in);
if (!(len == 4 && line && strcmp (line, "foo\n") == 0))
- return 2;
+ { free (line); fclose (in); return 2; }
free (line);
}
{
char *line = NULL;
size_t siz = (size_t)(~0) / 4;
if (getline (&line, &siz, in) == -1)
- return 3;
+ { fclose (in); return 3; }
free (line);
}
fclose (in);
-# iconv.m4 serial 20
+# iconv.m4 serial 21
dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
#endif
/* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is
provided. */
- if (/* Try standardized names. */
- iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1)
- /* Try IRIX, OSF/1 names. */
- && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1)
- /* Try AIX names. */
- && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1)
- /* Try HP-UX names. */
- && iconv_open ("utf8", "eucJP") == (iconv_t)(-1))
- result |= 16;
+ {
+ /* Try standardized names. */
+ iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");
+ /* Try IRIX, OSF/1 names. */
+ iconv_t cd2 = iconv_open ("UTF-8", "eucJP");
+ /* Try AIX names. */
+ iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");
+ /* Try HP-UX names. */
+ iconv_t cd4 = iconv_open ("utf8", "eucJP");
+ if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)
+ && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))
+ result |= 16;
+ if (cd1 != (iconv_t)(-1))
+ iconv_close (cd1);
+ if (cd2 != (iconv_t)(-1))
+ iconv_close (cd2);
+ if (cd3 != (iconv_t)(-1))
+ iconv_close (cd3);
+ if (cd4 != (iconv_t)(-1))
+ iconv_close (cd4);
+ }
return result;
]])],
[am_cv_func_iconv_works=yes], ,
-# memmem.m4 serial 24
+# memmem.m4 serial 25
dnl Copyright (C) 2002-2004, 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if (!memmem (haystack, 2 * m + 1, needle, m + 1))
result |= 1;
}
+ /* Free allocated memory, in case some sanitizer is watching. */
+ free (haystack);
+ free (needle);
return result;
]])],
[gl_cv_func_memmem_works_fast=yes], [gl_cv_func_memmem_works_fast=no],
-# serial 10
+# serial 11
# Copyright (C) 2000-2001, 2005-2006, 2009-2017 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
val = errno;
s = fopen ("confdir2/errno", "w");
fprintf (s, "%d\n", val);
+ fclose (s);
return 0;
}
]])],
-# signbit.m4 serial 13
+# signbit.m4 serial 14
dnl Copyright (C) 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
{
/* More than one bit difference. */
fprintf (fp, "unknown");
+ fclose (fp);
return 2;
}
if (x)
{
/* No difference. */
fprintf (fp, "unknown");
+ fclose (fp);
return 3;
}
/* Now m = plus.word[k] ^ ~minus.word[k]. */
/* Oh? The sign bit is set in the positive and cleared in the negative
numbers? */
fprintf (fp, "unknown");
+ fclose (fp);
return 4;
}
for (i = 0; ; i++)
-# strcasestr.m4 serial 21
+# strcasestr.m4 serial 22
dnl Copyright (C) 2005, 2007-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if (!strcasestr (haystack, needle))
result |= 1;
}
+ /* Free allocated memory, in case some sanitizer is watching. */
+ free (haystack);
+ free (needle);
return result;
]])],
[gl_cv_func_strcasestr_linear=yes], [gl_cv_func_strcasestr_linear=no],
-# strstr.m4 serial 17
+# strstr.m4 serial 18
dnl Copyright (C) 2008-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
if (!strstr (haystack, needle))
result |= 1;
}
+ /* Free allocated memory, in case some sanitizer is watching. */
+ free (haystack);
+ free (needle);
return result;
]])],
[gl_cv_func_strstr_linear=yes], [gl_cv_func_strstr_linear=no],
-# ungetc.m4 serial 3
+# ungetc.m4 serial 4
dnl Copyright (C) 2009-2017 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
]], [FILE *f;
- if (!(f = fopen ("conftest.tmp", "w+"))) return 1;
- if (fputs ("abc", f) < 0) return 2;
+ if (!(f = fopen ("conftest.tmp", "w+")))
+ return 1;
+ if (fputs ("abc", f) < 0)
+ { fclose (f); return 2; }
rewind (f);
- if (fgetc (f) != 'a') return 3;
- if (fgetc (f) != 'b') return 4;
- if (ungetc ('d', f) != 'd') return 5;
- if (ftell (f) != 1) return 6;
- if (fgetc (f) != 'd') return 7;
- if (ftell (f) != 2) return 8;
- if (fseek (f, 0, SEEK_CUR) != 0) return 9;
- if (ftell (f) != 2) return 10;
- if (fgetc (f) != 'c') return 11;
- fclose (f); remove ("conftest.tmp");])],
+ if (fgetc (f) != 'a')
+ { fclose (f); return 3; }
+ if (fgetc (f) != 'b')
+ { fclose (f); return 4; }
+ if (ungetc ('d', f) != 'd')
+ { fclose (f); return 5; }
+ if (ftell (f) != 1)
+ { fclose (f); return 6; }
+ if (fgetc (f) != 'd')
+ { fclose (f); return 7; }
+ if (ftell (f) != 2)
+ { fclose (f); return 8; }
+ if (fseek (f, 0, SEEK_CUR) != 0)
+ { fclose (f); return 9; }
+ if (ftell (f) != 2)
+ { fclose (f); return 10; }
+ if (fgetc (f) != 'c')
+ { fclose (f); return 11; }
+ fclose (f);
+ remove ("conftest.tmp");])],
[gl_cv_func_ungetc_works=yes], [gl_cv_func_ungetc_works=no],
[case "$host_os" in
# Guess yes on glibc and bionic systems.