eet - fix write denied - no seg on dict free + check on open

@fix
This commit is contained in:
Carsten Haitzler 2023-12-19 11:02:29 +00:00
parent 9d7fc64ca3
commit 9447fb6bad
2 changed files with 14 additions and 4 deletions

View File

@ -31,11 +31,14 @@ eet_dictionary_free(Eet_Dictionary *ed)
if (!ed) return;
eina_rwlock_free(&ed->rwlock);
for (i = 0; i < ed->count; i++)
if ((ed->all_allocated) && (ed->all))
{
if (ed->all_allocated[i >> 3] & (1 << (i & 0x7)))
for (i = 0; i < ed->count; i++)
{
eina_stringshare_del(ed->all[i].str);
if (ed->all_allocated[i >> 3] & (1 << (i & 0x7)))
{
eina_stringshare_del(ed->all[i].str);
}
}
}
free(ed->all);

View File

@ -1527,7 +1527,7 @@ eet_open(const char *file,
{
Eina_File *fp;
Eet_File *ef;
int file_len;
int file_len, ret;
unsigned long int size;
if (!file)
@ -1566,6 +1566,11 @@ eet_open(const char *file,
/* try open the file based on mode */
if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
{
if (mode == EET_FILE_MODE_READ_WRITE)
{
ret = access(file, W_OK);
if ((ret != 0) && (errno != ENOENT)) return NULL;
}
/* Prevent garbage in futur comparison. */
fp = eina_file_open(file, EINA_FALSE);
if (!fp)
@ -1601,6 +1606,8 @@ open_error:
size = 0;
fp = NULL;
ret = access(file, W_OK);
if ((ret != 0) && (errno != ENOENT)) return NULL;
}
/* We found one */