]> Savannah Git Hosting - gnulib.git/commitdiff
*printf-posix: Avoid crash in another configure test.
authorBruno Haible <bruno@clisp.org>
Wed, 21 Feb 2024 11:51:01 +0000 (12:51 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 21 Feb 2024 11:51:01 +0000 (12:51 +0100)
* m4/printf.m4 (gl_SNPRINTF_DIRECTIVE_N): In the test program, catch the
SIGABRT signal, so that the program does not dump core.

ChangeLog
m4/printf.m4

index dfc1641e74b9e1f36310581bf056967db6f9e272..766d4c798dfa6441bd968978303879a60ac51240 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-02-21  Bruno Haible  <bruno@clisp.org>
+
+       *printf-posix: Avoid crash in another configure test.
+       * m4/printf.m4 (gl_SNPRINTF_DIRECTIVE_N): In the test program, catch the
+       SIGABRT signal, so that the program does not dump core.
+
 2024-02-20  Bruno Haible  <bruno@clisp.org>
 
        unimetadata/u-version: Add tests.
index 05bf7fe1dfae8f4cbbdfafd9cd2c8ad96ad006fc..6f917778e849e8b34ea1d69d395ad787126f7012 100644 (file)
@@ -1705,6 +1705,7 @@ AC_DEFUN([gl_SNPRINTF_DIRECTIVE_N],
     [
       AC_RUN_IFELSE(
         [AC_LANG_SOURCE([[
+#include <signal.h>
 #include <stdio.h>
 #include <string.h>
 #if HAVE_SNPRINTF
@@ -1721,11 +1722,18 @@ static int my_snprintf (char *buf, int size, const char *format, ...)
   return ret;
 }
 #endif
+static void
+abort_handler (int sig)
+{
+  (void) sig;
+  _exit (1);
+}
 static char fmtstring[10];
 static char buf[100];
 int main ()
 {
   int count = -1;
+  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.  */