elementary: correctly check error in elm_cnp.

SVN revision: 80576
This commit is contained in:
Cedric BAIL 2012-12-10 08:01:16 +00:00
parent 8aef42c60e
commit e7ca3a31d0
3 changed files with 18 additions and 22 deletions

View File

@ -800,3 +800,4 @@
2012-12-10 Cedric Bail 2012-12-10 Cedric Bail
* Make sure private data is not NULL in elm_interface_scrollable. * Make sure private data is not NULL in elm_interface_scrollable.
* Correctly handle failure case in _x11_notify_handler_image.

View File

@ -87,6 +87,7 @@ Fixes:
* Simplify test in elm_entry_text_set. * Simplify test in elm_entry_text_set.
* Fix focus problem in multibuttonentry. Entry can get focus only when multibuttonentry is focused. * 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. * Make sure private data is not NULL in elm_interface_scrollable.
* Correctly handle failure case in _x11_notify_handler_image.
Removals: Removals:

View File

@ -830,6 +830,7 @@ _x11_notify_handler_image(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify
} }
/* generate tmp name */ /* generate tmp name */
tmp = _tempfile_new(data->length); tmp = _tempfile_new(data->length);
if (!tmp) return 0;
memcpy(tmp->map, data->data, data->length); memcpy(tmp->map, data->data, data->length);
munmap(tmp->map, data->length); munmap(tmp->map, data->length);
/* FIXME: Add to paste image data to clean up */ /* FIXME: Add to paste image data to clean up */
@ -1880,22 +1881,15 @@ _tempfile_new(int size)
tmppath = getenv("TMP"); tmppath = getenv("TMP");
if (!tmppath) tmppath = P_tmpdir; if (!tmppath) tmppath = P_tmpdir;
len = snprintf(NULL, 0, "%s/%sXXXXXX", tmppath, "elmcnpitem-"); len = snprintf(NULL, 0, "%s/%sXXXXXX", tmppath, "elmcnpitem-");
if (len < 0) if (len < 0) goto on_error;
{
free(info);
return NULL;
}
len++; len++;
info->filename = malloc(len); info->filename = malloc(len);
if (!info->filename) if (!info->filename) goto on_error;
{
free(info);
return NULL;
}
snprintf(info->filename,len,"%s/%sXXXXXX", tmppath, "elmcnpitem-"); snprintf(info->filename,len,"%s/%sXXXXXX", tmppath, "elmcnpitem-");
cur_umask = umask(S_IRWXO | S_IRWXG); cur_umask = umask(S_IRWXO | S_IRWXG);
info->fd = mkstemp(info->filename); info->fd = mkstemp(info->filename);
umask(cur_umask); umask(cur_umask);
if (info->fd < 0) goto on_error;
# ifdef __linux__ # ifdef __linux__
{ {
char *tmp; char *tmp;
@ -1917,30 +1911,30 @@ _tempfile_new(int size)
} }
# endif # endif
cnp_debug("filename is %s\n", info->filename); cnp_debug("filename is %s\n", info->filename);
if (size < 1) if (size < 1) goto on_error;
{
/* Set map to NULL and return */
info->map = NULL;
info->len = 0;
return info;
}
/* Map it in */ /* Map it in */
if (ftruncate(info->fd, size)) if (ftruncate(info->fd, size))
{ {
perror("ftruncate"); perror("ftruncate");
info->map = NULL; goto on_error;
info->len = 0;
return info;
} }
eina_mmap_safety_enabled_set(EINA_TRUE); eina_mmap_safety_enabled_set(EINA_TRUE);
info->map = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, info->fd, 0); info->map = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, info->fd, 0);
if (info->map == MAP_FAILED) if (info->map == MAP_FAILED)
{ {
perror("mmap"); perror("mmap");
info->map = NULL; goto on_error;
info->len = 0;
} }
return info; 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 #else
(void) size; (void) size;
return NULL; return NULL;