forked from enlightenment/efl
eet: Stopped SPANKing the naughty programmer while deleting dictionary.
Function edje_edit_save_all cause lots of SPANK SPANK, because eet_dictionary_free is trying to delete string that is actually not a stringshare. Reviewers: cedric, seoz, raster Reviewed By: cedric CC: reutskiy.v.v, cedric Differential Revision: https://phab.enlightenment.org/D322 Signed-off-by: Cedric Bail <cedric.bail@samsung.com>
This commit is contained in:
parent
ff71f7452a
commit
c3bee34c3c
|
@ -36,7 +36,7 @@ eet_dictionary_free(Eet_Dictionary *ed)
|
||||||
eina_spinlock_free(&ed->mutex);
|
eina_spinlock_free(&ed->mutex);
|
||||||
|
|
||||||
for (i = 0; i < ed->count; ++i)
|
for (i = 0; i < ed->count; ++i)
|
||||||
if (ed->all_allocated[i >> 8] & (1 << (i & 0x7)))
|
if (ed->all_allocated[i >> 3] & (1 << (i & 0x7)))
|
||||||
eina_stringshare_del(ed->all[i].str);
|
eina_stringshare_del(ed->all[i].str);
|
||||||
|
|
||||||
free(ed->all);
|
free(ed->all);
|
||||||
|
@ -152,7 +152,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
|
|
||||||
current = ed->all + ed->count;
|
current = ed->all + ed->count;
|
||||||
|
|
||||||
ed->all_allocated[ed->count >> 8] |= (1 << (ed->count & 0x7));
|
ed->all_allocated[ed->count >> 3] |= (1 << (ed->count & 0x7));
|
||||||
ed->all_hash[ed->count] = hash;
|
ed->all_hash[ed->count] = hash;
|
||||||
|
|
||||||
current->str = str;
|
current->str = str;
|
||||||
|
@ -246,10 +246,10 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed,
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* Windows file system could change the mmaped file when replacing a file. So we need to copy all string in memory to avoid bugs. */
|
/* Windows file system could change the mmaped file when replacing a file. So we need to copy all string in memory to avoid bugs. */
|
||||||
if (!(ed->all_allocated[idx >> 8] & (1 << (idx & 0x7))))
|
if (!(ed->all_allocated[idx >> 3] & (1 << (idx & 0x7))))
|
||||||
{
|
{
|
||||||
ed->all[idx].str = eina_stringshare_add(ed->all[idx].str);
|
ed->all[idx].str = eina_stringshare_add(ed->all[idx].str);
|
||||||
ed->all_allocated[idx >> 8] |= (1 << (idx & 0x7));
|
ed->all_allocated[idx >> 3] |= (1 << (idx & 0x7));
|
||||||
}
|
}
|
||||||
#endif /* ifdef _WIN32 */
|
#endif /* ifdef _WIN32 */
|
||||||
s = ed->all[idx].str;
|
s = ed->all[idx].str;
|
||||||
|
@ -513,7 +513,7 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
for (i = 0; i < ed->count; ++i)
|
for (i = 0; i < ed->count; ++i)
|
||||||
if ((ed->all_allocated[i >> 8] & (1 << (i & 0x7))) && ed->all[i].str == string)
|
if ((ed->all_allocated[i >> 3] & (1 << (i & 0x7))) && ed->all[i].str == string)
|
||||||
{
|
{
|
||||||
res = 1;
|
res = 1;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue