[PATCH] tst-scanf-format-real: don't crash on nan()

Andreas Schwab schwab@suse.de
Wed Apr 9 13:22:18 GMT 2025


Fix a null-pointer dereference when the expected value is written as
`nan()'.
---
 stdio-common/tst-scanf-format-real.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/stdio-common/tst-scanf-format-real.h b/stdio-common/tst-scanf-format-real.h
index 639ac74973..07a276d4ec 100644
--- a/stdio-common/tst-scanf-format-real.h
+++ b/stdio-common/tst-scanf-format-real.h
@@ -201,7 +201,7 @@ out:									\
 	  }								\
 									\
 	size_t seq_size = 0;						\
-	char *seq = NULL;						\
+	char *seq = xstrdup ("");					\
 	i = 0;								\
 	if (ch == '(')							\
 	  while (1)							\
-- 
2.49.0


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Libc-alpha mailing list