diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-10-28 19:36:34 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-10-28 19:36:34 (GMT) |
| commit | 1f6c360968fab22aa02a30a72c196a8f8eb19c0c (patch) | |
| tree | c490d9cba824ba803b713fe06b6ccfb7f98caca3 /generic/tclHash.c | |
| parent | 63b8d1466dca7693cf0f6b61d39fada6fd1e0e7f (diff) | |
| parent | ccb97d88ffefe602e7eb5a9610bd356d66bc2f20 (diff) | |
| download | tcl-1f6c360968fab22aa02a30a72c196a8f8eb19c0c.zip tcl-1f6c360968fab22aa02a30a72c196a8f8eb19c0c.tar.gz tcl-1f6c360968fab22aa02a30a72c196a8f8eb19c0c.tar.bz2 | |
Merge tip-468 branch
Diffstat (limited to 'generic/tclHash.c')
| -rw-r--r-- | generic/tclHash.c | 26 |
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. |
