Skip to content
Tcl Source Code View Ticket
Login

View Ticket

overflow trouble in [string repeat]

Closed / Fixed2561746fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2009-02-03 19:18:48
% info patch
8.5.6
% set a [string repeat a 0x80000000]; concat
% string length $a
0
dgpplain2009-02-04 02:20:41
Related:

% set a [string repeat a 0x7fffffff]; concat
string size overflow, out of memory allocating -2147483648 bytes

Here it's just the formatting of the
error message that is the problem.
dgpplain2009-02-04 02:32:12
On another system with more memory:

% set a [string repeat a 0x7fffffff]; concat
Segmentation fault
dgpplain2009-02-04 02:43:45
Fix for 714106 is apparently incomplete.
dgpplain2009-02-04 23:20:33
the existing overflow protections are
only effective for repeated substrings
of length > 1.
dgpplain2009-02-05 01:14:12
Note that the original report here
is *not a bug* but a bit of compatibility.
The count values from 0x80000000 to 0xffffffff
are taken as equivalent to the values
-0x80000000 to -1 because the value is
fetched with Tcl_GetIntFromObj().

Then, given a negative count value, 
[string repeat] returns an empty string
and no error.

The later comments note the real bug,
some uncaught overflows leading to
crashes.
dgpplain2009-02-05 01:16:09
fix committed to HEAD.
backports still needed.
dgpplain2009-02-05 02:04:44
allow_comments - 1


Backported for 8.5.7.  Not buggy in 8.4. branch.
Log in (anonymous is fine) to add a comment.