Ephoto: Fix coverity issues: CID 151524, 151521, 151520, 151518, 151517, 151516, 151515, 151512

This commit is contained in:
Stephen okra Houston 2016-11-28 10:30:29 -06:00
parent edd58aa3a6
commit 621fb3be0b
3 changed files with 70 additions and 51 deletions

View File

@ -1168,13 +1168,10 @@ ephoto_directory_browser_initialize_structure(Ephoto *ephoto)
dir = ecore_file_dir_get(path); dir = ecore_file_dir_get(path);
dirs = eina_list_prepend(dirs, strdup(dir)); dirs = eina_list_prepend(dirs, strdup(dir));
memset(path, 0x00, sizeof(path)); memset(path, 0x00, sizeof(path));
snprintf(path, PATH_MAX, "%s", dir); snprintf(path, PATH_MAX, "%s", dir);
}
if (dir)
{
free(dir);
dir = NULL;
} }
free(dir);
dir = NULL;
} }
} }
EINA_LIST_FOREACH(dirs, l, dir) EINA_LIST_FOREACH(dirs, l, dir)
@ -1224,13 +1221,13 @@ ephoto_directory_browser_initialize_structure(Ephoto *ephoto)
{ {
_monitor_add(entry); _monitor_add(entry);
entry->genlist = db->fsel; entry->genlist = db->fsel;
} if (n)
if (n)
{
if (!strcmp(n, entry->path))
{ {
next = entry->item; if (!strcmp(n, entry->path))
elm_genlist_item_expanded_set(next, EINA_TRUE); {
next = entry->item;
elm_genlist_item_expanded_set(next, EINA_TRUE);
}
} }
} }
} }
@ -1253,6 +1250,7 @@ ephoto_directory_browser_initialize_structure(Ephoto *ephoto)
} }
ephoto_title_set(ephoto, ephoto->config->directory); ephoto_title_set(ephoto, ephoto->config->directory);
db->initializing = EINA_FALSE; db->initializing = EINA_FALSE;
free(end_dir);
} }
Evas_Object * Evas_Object *

View File

@ -744,38 +744,40 @@ _delete_thread_cb(void *data, Ecore_Thread *et EINA_UNUSED)
int ret; int ret;
struct stat s; struct stat s;
lstat(file, &s); if (lstat(file, &s))
if (S_ISLNK(s.st_mode))
{ {
ret = ecore_file_unlink(file); if (S_ISLNK(s.st_mode))
} {
else ret = ecore_file_unlink(file);
{ }
snprintf(fp, PATH_MAX, "%s", file);
snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
if (ecore_file_exists(dest))
{
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
basename(fp));
if (ecore_file_exists(extra))
{
int count;
for (count = 2; ecore_file_exists(extra); count++)
{
memset(extra, 0, sizeof(extra));
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
destination, count, basename(fp));
}
}
ret = ecore_file_mv(file, extra);
}
else else
ret = ecore_file_mv(file, dest); {
} snprintf(fp, PATH_MAX, "%s", file);
if (!ret) snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
ephoto->file_errors++; if (ecore_file_exists(dest))
} {
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
basename(fp));
if (ecore_file_exists(extra))
{
int count;
for (count = 2; ecore_file_exists(extra); count++)
{
memset(extra, 0, sizeof(extra));
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
destination, count, basename(fp));
}
}
ret = ecore_file_mv(file, extra);
}
else
ret = ecore_file_mv(file, dest);
}
if (!ret)
ephoto->file_errors++;
}
}
} }
} }
@ -919,11 +921,21 @@ _prompt_upload_apply(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_show(popup); evas_object_show(popup);
f = fopen(entry->path, "rb"); f = fopen(entry->path, "rb");
if (!f) CRIT("unable to open '%s': %s", entry->path, strerror(errno)); if (!f)
{
CRIT("unable to open '%s': %s", entry->path, strerror(errno));
evas_object_del(popup);
return;
}
res = fseek(f, 0, SEEK_END); res = fseek(f, 0, SEEK_END);
if (!res) CRIT("fseek() failed on file '%s': %s", entry->path, strerror(errno)); if (!res) CRIT("fseek() failed on file '%s': %s", entry->path, strerror(errno));
fsize = ftell(f); fsize = ftell(f);
if (fsize == -1) CRIT("ftell() failed on file '%s': %s", entry->path, strerror(errno)); if (fsize == -1)
{
CRIT("ftell() failed on file '%s': %s", entry->path, strerror(errno));
evas_object_del(popup);
return;
}
rewind(f); rewind(f);
fdata = malloc(fsize); fdata = malloc(fsize);
res = fread(fdata, fsize, 1, f); res = fread(fdata, fsize, 1, f);
@ -1007,16 +1019,22 @@ _prompt_save_image_as_apply(void *data, Evas_Object *obj, void *event_info)
else else
{ {
ext = eina_stringshare_add((strrchr(selected, '.')+1)); ext = eina_stringshare_add((strrchr(selected, '.')+1));
if (!_ephoto_file_image_can_save(ext)) if (ext)
{ {
if (ext) if (!_ephoto_file_image_can_save(ext))
eina_stringshare_del(ext); {
snprintf(buf, PATH_MAX, "%s.jpg", selected); eina_stringshare_del(ext);
snprintf(buf, PATH_MAX, "%s.jpg", selected);
}
else
{
eina_stringshare_del(ext);
snprintf(buf, PATH_MAX, "%s", selected);
}
} }
else else
{ {
if (ext) eina_stringshare_del(ext);
eina_stringshare_del(ext);
snprintf(buf, PATH_MAX, "%s", selected); snprintf(buf, PATH_MAX, "%s", selected);
} }
} }

View File

@ -995,7 +995,10 @@ ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
ed->thumbs_only = thumbs_only; ed->thumbs_only = thumbs_only;
if (!ecore_file_can_read(path)) if (!ecore_file_can_read(path))
return; {
free(ed);
return;
}
EINA_LIST_FREE(ed->ephoto->thumbs, o) EINA_LIST_FREE(ed->ephoto->thumbs, o)
evas_object_del(o); evas_object_del(o);