diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2023-05-19 12:02:49 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2023-05-19 12:02:49 (GMT) |
| commit | b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c (patch) | |
| tree | b744be174ece6b694da314852f5e1143ba086c48 /generic/tclScan.c | |
| parent | fea912c676a71b362b8c7d77e3f4242e374de1bb (diff) | |
| parent | e47cbdc798e9744e9a89840e9ace30186872a762 (diff) | |
| download | tcl-b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c.zip tcl-b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c.tar.gz tcl-b0f19e41f2c3e29950af3fb586b0f7a7f9112b2c.tar.bz2 | |
merge core-8-branch
Diffstat (limited to 'generic/tclScan.c')
| -rw-r--r-- | generic/tclScan.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/generic/tclScan.c b/generic/tclScan.c index c200fa0..f332d24 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -306,7 +306,7 @@ ValidateFormat( * format string. */ - value = strtoul(format-1, &end, 10); /* INTL: "C" locale. */ + unsigned long ul = strtoul(format-1, &end, 10); /* INTL: "C" locale. */ if (*end != '$') { goto notXpg; } @@ -316,17 +316,20 @@ ValidateFormat( if (gotSequential) { goto mixedXPG; } - objIndex = value - 1; - if ((objIndex < 0) || (numVars && (objIndex >= numVars))) { + if (ul == 0 || ul >= INT_MAX) { + goto badIndex; + } + objIndex = (int) ul - 1; + if (numVars && (objIndex >= numVars)) { goto badIndex; } else if (numVars == 0) { /* * In the case where no vars are specified, the user can * specify %9999$ legally, so we have to consider special - * rules for growing the assign array. 'value' is guaranteed - * to be > 0. + * rules for growing the assign array. 'ul' is guaranteed + * to be > 0 and < INT_MAX as per checks above. */ - xpgSize = (xpgSize > value) ? xpgSize : value; + xpgSize = (xpgSize > (int)ul) ? xpgSize : (int)ul; } goto xpgCheckDone; } |
