1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
--- a/src/lib_string.c
+++ b/src/lib_string.c
@@ -746,6 +746,7 @@
nbuf[len-2] = nbuf[len-2] - 0x20;
nbuf[len-1] = nbuf[len-1] - 0x20;
}
+ nbuf[len] = '\0';
for (p = form; *p < 'e' && *p != '.'; p++) ;
*p++ = 's'; *p = '\0';
sprintf(buff, form, nbuf);
--- a/src/lj_state.c
+++ b/src/lj_state.c
@@ -153,26 +153,21 @@
static void close_state(lua_State *L)
{
global_State *g = G(L);
+ lj_func_closeuv(L, L->stack);
+ lj_gc_freeall(g);
+ lua_assert(gcref(g->gc.root) == obj2gco(L));
+ lua_assert(g->strnum == 0);
+ lj_trace_freestate(g);
+ lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
+ lj_str_freebuf(g, &g->tmpbuf);
+ lj_mem_freevec(g, L->stack, L->stacksize, TValue);
+ lua_assert(g->gc.total == sizeof(GG_State));
#ifndef LUAJIT_USE_SYSMALLOC
- if (g->allocf == lj_alloc_f) {
-#if LJ_HASJIT
- lj_mcode_free(G2J(g));
-#endif
+ if (g->allocf == lj_alloc_f)
lj_alloc_destroy(g->allocd);
- } else
+ else
#endif
- {
- lj_func_closeuv(L, L->stack);
- lj_gc_freeall(g);
- lua_assert(gcref(g->gc.root) == obj2gco(L));
- lua_assert(g->strnum == 0);
- lj_trace_freestate(g);
- lj_mem_freevec(g, g->strhash, g->strmask+1, GCRef);
- lj_str_freebuf(g, &g->tmpbuf);
- lj_mem_freevec(g, L->stack, L->stacksize, TValue);
- lua_assert(g->gc.total == sizeof(GG_State));
g->allocf(g->allocd, G2GG(g), sizeof(GG_State), 0);
- }
}
#if LJ_64
|