diff options
| author | dgp <dgp@users.sourceforge.net> | 2017-11-08 03:23:35 (GMT) |
|---|---|---|
| committer | dgp <dgp@users.sourceforge.net> | 2017-11-08 03:23:35 (GMT) |
| commit | dee7abd87b35462e5ce0b8a90d9e19c23033f55b (patch) | |
| tree | fc43eea1d4201ba7b52fb5e2e6d47c7eba6226a1 /generic/tclHash.c | |
| parent | 7417e2c917cb95b23924d92c441410571ed17a52 (diff) | |
| parent | e82d7fb7538c87bbe0c63263e2032fe02a5a100b (diff) | |
| download | tcl-dee7abd87b35462e5ce0b8a90d9e19c23033f55b.zip tcl-dee7abd87b35462e5ce0b8a90d9e19c23033f55b.tar.gz tcl-dee7abd87b35462e5ce0b8a90d9e19c23033f55b.tar.bz2 | |
merge trunk
Diffstat (limited to 'generic/tclHash.c')
| -rw-r--r-- | generic/tclHash.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c index bb899de..e724bf7 100644 --- a/generic/tclHash.c +++ b/generic/tclHash.c @@ -941,12 +941,18 @@ static void RebuildTable( register Tcl_HashTable *tablePtr) /* Table to enlarge. */ { - size_t oldSize, count, index; - Tcl_HashEntry **oldBuckets; + size_t count, index, oldSize = tablePtr->numBuckets; + Tcl_HashEntry **oldBuckets = tablePtr->buckets; register Tcl_HashEntry **oldChainPtr, **newChainPtr; register Tcl_HashEntry *hPtr; const Tcl_HashKeyType *typePtr; + /* Avoid outgrowing capability of the memory allocators */ + if (oldSize > UINT_MAX / (4 * sizeof(Tcl_HashEntry *))) { + tablePtr->rebuildSize = INT_MAX; + return; + } + if (tablePtr->keyType == TCL_STRING_KEYS) { typePtr = &tclStringHashKeyType; } else if (tablePtr->keyType == TCL_ONE_WORD_KEYS) { @@ -958,9 +964,6 @@ RebuildTable( typePtr = &tclArrayHashKeyType; } - oldSize = tablePtr->numBuckets; - oldBuckets = tablePtr->buckets; - /* * Allocate and initialize the new bucket array, and set up hashing * constants for new array size. |
