summaryrefslogtreecommitdiffstats
path: root/generic/tclHash.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-03-15 13:40:40 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-03-15 13:40:40 (GMT)
commit26e714137a987c67af5a932fdaf7bd1138d97a2d (patch)
tree9358f84805ded45680d28bba41db129dfafb91e2 /generic/tclHash.c
parenta457b16dfc3bd4a4db9171364cd2a5ab04392bb8 (diff)
parentaa199edba612a516e6309290fb6dc4442a49a5ee (diff)
downloadtcl-26e714137a987c67af5a932fdaf7bd1138d97a2d.zip
tcl-26e714137a987c67af5a932fdaf7bd1138d97a2d.tar.gz
tcl-26e714137a987c67af5a932fdaf7bd1138d97a2d.tar.bz2
merge 8.7
Diffstat (limited to 'generic/tclHash.c')
-rw-r--r--generic/tclHash.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/generic/tclHash.c b/generic/tclHash.c
index 78ad514..32c9aec 100644
--- a/generic/tclHash.c
+++ b/generic/tclHash.c
@@ -46,19 +46,6 @@ static int CompareArrayKeys(void *keyPtr, Tcl_HashEntry *hPtr);
static TCL_HASH_TYPE HashArrayKey(Tcl_HashTable *tablePtr, void *keyPtr);
/*
- * Prototypes for the one word hash key methods. Not actually declared because
- * this is a critical path that is implemented in the core hash table access
- * function.
- */
-
-#if 0
-static Tcl_HashEntry * AllocOneWordEntry(Tcl_HashTable *tablePtr,
- void *keyPtr);
-static int CompareOneWordKeys(void *keyPtr, Tcl_HashEntry *hPtr);
-static unsigned int HashOneWordKey(Tcl_HashTable *tablePtr, void *keyPtr);
-#endif
-
-/*
* Prototypes for the string hash key methods.
*/
@@ -998,12 +985,18 @@ static void
RebuildTable(
register Tcl_HashTable *tablePtr) /* Table to enlarge. */
{
- int oldSize, count, index;
- Tcl_HashEntry **oldBuckets;
+ int 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 > (int)(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) {
@@ -1015,9 +1008,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.