Check if malloc failed, if the file exists/can be accessed and set the
appropriate error codes.
--
André Dieb Martins
Embedded Systems and Pervasive Computing Lab (Embedded)
Electrical Engineering Department (DEE)
Center of Electrical Engineering and Informatics (CEEI)
Federal University of Campina Grande (UFCG)
Blog: http://genuinepulse.blogspot.com/
Index: src/lib/eina_module.c
===================================================================
--- src/lib/eina_module.c (revision 40899)
+++ src/lib/eina_module.c (working copy)
@@ -28,6 +28,7 @@
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
+#include <sys/stat.h>
#ifdef HAVE_ALLOCA_H
# include <alloca.h>
@@ -260,11 +261,25 @@
EAPI Eina_Module * eina_module_new(const char *file)
{
Eina_Module *m;
+ struct stat stat_info;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
- /* TODO check that the file exists */
+ if (stat(file, &stat_info) != 0)
+ {
+ // Could not retrieve information about the file
+ eina_error_set(EINA_ERROR_WRONG_MODULE);
+ return NULL;
+ }
+
m = malloc(sizeof(Eina_Module));
+
+ if (!m)
+ {
+ eina_error_set(EINA_ERROR_OUT_OF_MEMORY);
+ return NULL;
+ }
+
/* TODO add the magic */
m->file = strdup(file);
m->ref = 0;
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel