diff --git a/src/hlua.c b/src/hlua.c index 844a5ec9d..8bc831944 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -1512,7 +1512,9 @@ __LJMP static int hlua_map_new(struct lua_State *L) /* fill fake args. */ args[0].type = ARGT_STR; - args[0].data.str.area = (char *)fn; + args[0].data.str.area = strdup(fn); + args[0].data.str.data = strlen(fn); + args[0].data.str.size = args[0].data.str.data+1; args[1].type = ARGT_STOP; /* load the map. */ @@ -1524,6 +1526,7 @@ __LJMP static int hlua_map_new(struct lua_State *L) lua_pushfstring(L, "'new': %s.", err); lua_concat(L, 2); free(err); + free(args[0].data.str.area); WILL_LJMP(lua_error(L)); }