mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 08:38:23 +00:00
util.c: assert that format strings are not empty
If any of these format strings are empty, things can go very wrong at runtime, from garbage output to segfaults (e.g. see #22375). This is a static check, so it could be placed in any source file. I chose util.c because according to the comment at the top, it is the home of "any stuff that people couldn't think of a better place for".
This commit is contained in:
parent
335f06f026
commit
c5df4fd101
17
util.c
17
util.c
@ -121,6 +121,23 @@ S_maybe_protect_ro(pTHX_ struct perl_memory_debug_header *header)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Sanity check: Format strings must not be empty */
|
||||
STATIC_ASSERT_DECL(sizeof I32df > 1);
|
||||
STATIC_ASSERT_DECL(sizeof U32of > 1);
|
||||
STATIC_ASSERT_DECL(sizeof U32uf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof U32xf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof U32Xf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof IVdf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof UVuf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof UVof > 1);
|
||||
STATIC_ASSERT_DECL(sizeof UVxf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof UVXf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof NVef > 1);
|
||||
STATIC_ASSERT_DECL(sizeof NVff > 1);
|
||||
STATIC_ASSERT_DECL(sizeof NVgf > 1);
|
||||
STATIC_ASSERT_DECL(sizeof Gid_t_f > 1);
|
||||
STATIC_ASSERT_DECL(sizeof Uid_t_f > 1);
|
||||
|
||||
/*
|
||||
=for apidoc_section $memory
|
||||
=for apidoc safesysmalloc
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user