forked from osmocom/wireshark
get_datafile_path() and get_persconffile_path() return malloc'd memory,
free it when we're done with the file name. svn path=/trunk/; revision=24479
This commit is contained in:
parent
2389b57232
commit
1d6df91a9d
|
@ -1191,6 +1191,8 @@ static void init_xml_names(void) {
|
|||
}
|
||||
}
|
||||
|
||||
g_free(dirname);
|
||||
|
||||
for(i=0;i<array_length(default_media_types);i++) {
|
||||
if( ! g_hash_table_lookup(media_types,default_media_types[i]) ) {
|
||||
g_hash_table_insert(media_types,(gpointer)default_media_types[i],&xml_ns);
|
||||
|
|
|
@ -274,6 +274,9 @@ int wslua_init(lua_State* LS) {
|
|||
lua_load_script(filename);
|
||||
}
|
||||
|
||||
g_free(filename);
|
||||
filename = NULL;
|
||||
|
||||
/* check if lua is to be disabled */
|
||||
lua_pushstring(L,"disable_lua");
|
||||
lua_gettable(L, LUA_GLOBALSINDEX);
|
||||
|
@ -300,6 +303,8 @@ int wslua_init(lua_State* LS) {
|
|||
|
||||
if (( file_exists(filename))) {
|
||||
lua_load_script(filename);
|
||||
g_free(filename);
|
||||
filename = NULL;
|
||||
}
|
||||
|
||||
while((filename = ex_opt_get_next("lua_script"))) {
|
||||
|
|
|
@ -144,6 +144,7 @@ WSLUA_FUNCTION wslua_debug( lua_State* L ) { /* Will add a log entry with debug
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* The returned filename was g_malloc()'d so the caller must free it */
|
||||
const char* wslua_get_actual_filename(const char* fname) {
|
||||
static char fname_clean[256];
|
||||
char* f;
|
||||
|
@ -170,6 +171,7 @@ const char* wslua_get_actual_filename(const char* fname) {
|
|||
if ( file_exists(filename) ) {
|
||||
return filename;
|
||||
}
|
||||
g_free(filename);
|
||||
|
||||
filename = get_datafile_path(fname_clean);
|
||||
|
||||
|
@ -188,8 +190,10 @@ WSLUA_FUNCTION wslua_loadfile(lua_State* L) {
|
|||
if (!filename) WSLUA_ARG_ERROR(loadfile,FILENAME,"file does not exist");
|
||||
|
||||
if (luaL_loadfile(L, filename) == 0) {
|
||||
g_free(filename);
|
||||
return 1;
|
||||
} else {
|
||||
g_free(filename);
|
||||
lua_pushnil(L);
|
||||
lua_insert(L, -2);
|
||||
return 2;
|
||||
|
@ -212,6 +216,7 @@ WSLUA_FUNCTION wslua_dofile(lua_State* L) {
|
|||
|
||||
n = lua_gettop(L);
|
||||
if (luaL_loadfile(L, filename) != 0) lua_error(L);
|
||||
g_free(filename);
|
||||
lua_call(L, 0, LUA_MULTRET);
|
||||
return lua_gettop(L) - n;
|
||||
}
|
||||
|
@ -256,6 +261,7 @@ WSLUA_CONSTRUCTOR Dir_open(lua_State* L) {
|
|||
|
||||
dir = g_malloc(sizeof(struct _wslua_dir));
|
||||
dir->dir = OPENDIR_OP(dirname_clean);
|
||||
g_free(dirname_clean);
|
||||
dir->ext = extension ? g_strdup(extension) : NULL;
|
||||
#if GLIB_MAJOR_VERSION >= 2
|
||||
dir->dummy = g_malloc(sizeof(GError *));
|
||||
|
|
Loading…
Reference in New Issue