On 10/4/11 2:48 PM, David Parks wrote: > Version: GNU bash, version 4.2.8(1)-release (x86_64-pc-linux-gnu) on Ubuntu > 10.04 > > If I set an associative array, as in: > > MYARRAY["something"]="Goobledygook" > > Then I set that same variable name again later (and so on in a loop). The > earlier variables are never released from memory, before I re-set a given > item I MUST call unset on the item first, possibly storing the value to a > temp variable if it's needed (such as is the case with a counter, for > example).
Thanks for the report. This will be fixed in the next bash release. I've attached a patch you can use to test. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2-patched/assoc.c 2009-08-05 20:19:40.000000000 -0400 --- assoc.c 2011-10-04 20:23:07.000000000 -0400 *************** *** 78,81 **** --- 78,86 ---- if (b == 0) return -1; + /* If we are overwriting an existing element's value, we're not going to + use the key. Nothing in the array assignment code path frees the key + string, so we can free it here to avoid a memory leak. */ + if (b->key != key) + free (key); FREE (b->data); b->data = value ? savestring (value) : (char *)0;