basename() can modify its argument, so get a copy first

SVN revision: 45228
This commit is contained in:
Vincent Torri 2010-01-16 16:41:24 +00:00
parent a165049986
commit e2a2448461
1 changed files with 9 additions and 2 deletions

View File

@ -45,6 +45,7 @@ void *alloca (size_t);
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <libgen.h>
#include <dlfcn.h>
@ -564,10 +565,16 @@ eina_module_find(const Eina_Array *array, const char *module)
EINA_ARRAY_ITER_NEXT(array, i, m, iterator)
{
const char *file_m;
char *file_m;
char *tmp;
ssize_t len;
file_m = basename(eina_module_file_get(m));
/* basename() can modify its argument, so we first get a copie */
/* do not use strdupa, as opensolaris does not have it */
len = strlen(eina_module_file_get(m));
tmp = alloca(len + 1);
memcpy(tmp, eina_module_file_get(m), len + 1);
file_m = basename(tmp);
len = strlen(file_m);
len -= sizeof(MODULE_EXTENSION) - 1;
if (len <= 0) continue;