]> Savannah Git Hosting - gnulib.git/commitdiff
*printf-posix: Avoid crash in a configure test.
authorBruno Haible <bruno@clisp.org>
Tue, 20 Feb 2024 11:06:37 +0000 (12:06 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 20 Feb 2024 11:07:41 +0000 (12:07 +0100)
* m4/printf.m4 (gl_PRINTF_DIRECTIVE_N): In the test program, catch the
SIGABRT signal, so that the program does not dump core.

ChangeLog
m4/printf.m4

index b941c7449d3f9b24b0e8622c11977aa6253b58b9..ef069e2e945aafb6c091ccfdde48ef002f2bc0e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-20  Bruno Haible  <bruno@clisp.org>
+
+       *printf-posix: Avoid crash in a configure test.
+       * m4/printf.m4 (gl_PRINTF_DIRECTIVE_N): In the test program, catch the
+       SIGABRT signal, so that the program does not dump core.
+
 2024-02-18  Jim Meyering  <meyering@meta.com>
 
        maint.mk: improve new syntax-check rule
index bb67d59409ebec73f269ff2d4bed2adc0238f045..05bf7fe1dfae8f4cbbdfafd9cd2c8ad96ad006fc 100644 (file)
@@ -1,4 +1,4 @@
-# printf.m4 serial 89
+# printf.m4 serial 90
 dnl Copyright (C) 2003, 2007-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -890,6 +890,7 @@ AC_DEFUN([gl_PRINTF_DIRECTIVE_N],
     [
       AC_RUN_IFELSE(
         [AC_LANG_SOURCE([[
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -907,6 +908,12 @@ invalid_parameter_handler (const wchar_t *expression,
   exit (1);
 }
 #endif
+static void
+abort_handler (int sig)
+{
+  (void) sig;
+  _exit (1);
+}
 static char fmtstring[10];
 static char buf[100];
 int main ()
@@ -915,6 +922,7 @@ int main ()
 #ifdef _MSC_VER
   _set_invalid_parameter_handler (invalid_parameter_handler);
 #endif
+  signal (SIGABRT, abort_handler);
   /* Copy the format string.  Some systems (glibc with _FORTIFY_SOURCE=2)
      support %n in format strings in read-only memory but not in writable
      memory.  */