forked from enlightenment/efl
elementary: correctly check error in elm_cnp.
SVN revision: 80576
This commit is contained in:
parent
8aef42c60e
commit
e7ca3a31d0
|
@ -800,3 +800,4 @@
|
|||
2012-12-10 Cedric Bail
|
||||
|
||||
* Make sure private data is not NULL in elm_interface_scrollable.
|
||||
* Correctly handle failure case in _x11_notify_handler_image.
|
||||
|
|
|
@ -87,6 +87,7 @@ Fixes:
|
|||
* Simplify test in elm_entry_text_set.
|
||||
* Fix focus problem in multibuttonentry. Entry can get focus only when multibuttonentry is focused.
|
||||
* Make sure private data is not NULL in elm_interface_scrollable.
|
||||
* Correctly handle failure case in _x11_notify_handler_image.
|
||||
|
||||
Removals:
|
||||
|
||||
|
|
|
@ -830,6 +830,7 @@ _x11_notify_handler_image(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify
|
|||
}
|
||||
/* generate tmp name */
|
||||
tmp = _tempfile_new(data->length);
|
||||
if (!tmp) return 0;
|
||||
memcpy(tmp->map, data->data, data->length);
|
||||
munmap(tmp->map, data->length);
|
||||
/* FIXME: Add to paste image data to clean up */
|
||||
|
@ -1880,22 +1881,15 @@ _tempfile_new(int size)
|
|||
tmppath = getenv("TMP");
|
||||
if (!tmppath) tmppath = P_tmpdir;
|
||||
len = snprintf(NULL, 0, "%s/%sXXXXXX", tmppath, "elmcnpitem-");
|
||||
if (len < 0)
|
||||
{
|
||||
free(info);
|
||||
return NULL;
|
||||
}
|
||||
if (len < 0) goto on_error;
|
||||
len++;
|
||||
info->filename = malloc(len);
|
||||
if (!info->filename)
|
||||
{
|
||||
free(info);
|
||||
return NULL;
|
||||
}
|
||||
if (!info->filename) goto on_error;
|
||||
snprintf(info->filename,len,"%s/%sXXXXXX", tmppath, "elmcnpitem-");
|
||||
cur_umask = umask(S_IRWXO | S_IRWXG);
|
||||
info->fd = mkstemp(info->filename);
|
||||
umask(cur_umask);
|
||||
if (info->fd < 0) goto on_error;
|
||||
# ifdef __linux__
|
||||
{
|
||||
char *tmp;
|
||||
|
@ -1917,30 +1911,30 @@ _tempfile_new(int size)
|
|||
}
|
||||
# endif
|
||||
cnp_debug("filename is %s\n", info->filename);
|
||||
if (size < 1)
|
||||
{
|
||||
/* Set map to NULL and return */
|
||||
info->map = NULL;
|
||||
info->len = 0;
|
||||
return info;
|
||||
}
|
||||
if (size < 1) goto on_error;
|
||||
/* Map it in */
|
||||
if (ftruncate(info->fd, size))
|
||||
{
|
||||
perror("ftruncate");
|
||||
info->map = NULL;
|
||||
info->len = 0;
|
||||
return info;
|
||||
goto on_error;
|
||||
}
|
||||
eina_mmap_safety_enabled_set(EINA_TRUE);
|
||||
info->map = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, info->fd, 0);
|
||||
if (info->map == MAP_FAILED)
|
||||
{
|
||||
perror("mmap");
|
||||
info->map = NULL;
|
||||
info->len = 0;
|
||||
goto on_error;
|
||||
}
|
||||
return info;
|
||||
|
||||
on_error:
|
||||
if (info->fd >= 0) close(info->fd);
|
||||
info->fd = -1;
|
||||
/* Set map to NULL and return */
|
||||
info->map = NULL;
|
||||
info->len = 0;
|
||||
free(info);
|
||||
return NULL;
|
||||
#else
|
||||
(void) size;
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue