* localtime.c (tzloadbody): Change ‘<=’ to ‘<’.
This fixes an obscure and unlikely performance bug,
where malloc was called when it need not have been called
in the !ALL_STATE case.
---
 localtime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/localtime.c b/localtime.c
index 7ab8aa41..3f3bdce5 100644
--- a/localtime.c
+++ b/localtime.c
@@ -800,7 +800,7 @@ tzloadbody(char const *name, struct state *sp, char 
tzloadflags,
                /* Create a string "TZDIR/NAME".  Using sprintf here
                   would pull in stdio (and would fail if the
                   resulting string length exceeded INT_MAX!).  */
-               if (ALL_STATE || sizeof *lsp <= fullnamesize) {
+               if (ALL_STATE || sizeof *lsp < fullnamesize) {
                  lsp = malloc(max(sizeof *lsp, fullnamesize));
                  if (!lsp)
                    return HAVE_MALLOC_ERRNO ? errno : ENOMEM;
-- 
2.48.1

Reply via email to