This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Add STATIC_ASSERT
authorKarl Williamson <khw@cpan.org>
Tue, 20 Feb 2018 04:15:21 +0000 (21:15 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 20 Feb 2018 04:20:16 +0000 (21:20 -0700)
I tried this in a smoke earlier, and got one failure, and to keep on
going, removed it temporarily.  But many other changes later, I tried
again in a smoke, and it isn't failing.  A legitimate failure of this
assertion would mean reading/writing past a buffer end.

locale.c

index 9f5f842..b22efac 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -582,6 +582,10 @@ S_emulate_setlocale(const int category,
         return (char *) querylocale(mask, cur_obj);
 
 #  else
+
+        /* If this assert fails, adjust the size of curlocales in intrpvar.h */
+        STATIC_ASSERT_STMT(C_ARRAY_LENGTH(PL_curlocales) > LC_ALL_INDEX);
+
 #    if defined(_NL_LOCALE_NAME) && defined(DEBUGGING)
 
         {