b = hash_search (key, hash, HASH_CREATE);
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;
return (0);
for (i = 0; i < hash->nbuckets; i++)
for (tlist = hash_items (i, hash); tlist; tlist = tlist->next)
{
+#if 1
+ if (sh_contains_shell_metas (tlist->key))
+ istr = sh_double_quote (tlist->key);
+ else
+ istr = tlist->key;
+#else
istr = tlist->key;
+#endif
vstr = tlist->data ? sh_double_quote ((char *)tlist->data) : (char *)0;
elen = STRLEN (istr) + 8 + STRLEN (vstr);
}
ret[rlen++] = ' ';
+
+ if (istr != tlist->key)
+ FREE (istr);
+
FREE (vstr);
}