Skip to content
Tcl Source Code Artifact [eed952ca37]
Login

Artifact [eed952ca37]

Artifact eed952ca3733de13cbbe9d6680f534851006d0335175e02b765408de24d128ae:

Attachment "fix.patch" to ticket [bdd1b346f8] added by bef on 2026-11-06 16:01:55.
--- a/generic/tclClockFmt.c
+++ b/generic/tclClockFmt.c
@@ -3401,6 +3401,7 @@
     ClockFormatToken *tok;
     const ClockFormatTokenMap *map;
     char resMem[MIN_FMT_RESULT_BLOCK_ALLOC];
+    size_t minAlloc;
 
     /* get localized format */
     if (ClockLocalizeFormat(opts) == NULL) {
@@ -3415,12 +3416,13 @@
     /* result container object */
     dateFmt->resMem = resMem;
     dateFmt->resEnd = dateFmt->resMem + sizeof(resMem);
-    if (fss->fmtMinAlloc > sizeof(resMem)) {
-	dateFmt->resMem = (char *)Tcl_AttemptAlloc(fss->fmtMinAlloc);
+    minAlloc = fss->fmtMinAlloc;	/* shared, read only once */
+    if (minAlloc > sizeof(resMem)) {
+	dateFmt->resMem = (char *)Tcl_AttemptAlloc(minAlloc);
 	if (dateFmt->resMem == NULL) {
 	    return TCL_ERROR;
 	}
-	dateFmt->resEnd = dateFmt->resMem + fss->fmtMinAlloc;
+	dateFmt->resEnd = dateFmt->resMem + minAlloc;
     }
     dateFmt->output = dateFmt->resMem;
     *dateFmt->output = '\0';