Skip to content

Commit 3e9360a

Browse files
att
1 parent 5e93859 commit 3e9360a

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

LuaCEmbed.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24120,9 +24120,10 @@ void privata_LuaCEmbed_decrement_stack(LuaCEmbed *self){
2412024120
}
2412124121

2412224122
void privateLuaCEmbd_get_field_protected(LuaCEmbed *self,const char *name){
24123+
bool old_field_proection = self->field_protection;
2412324124
self->field_protection = true;
2412424125
lua_getfield(self->state,-1,name);
24125-
self->field_protection = false;
24126+
self->field_protection = old_field_proection;
2412624127
}
2412724128

2412824129
void LuaCEmbed_free(LuaCEmbed *self){
@@ -24869,10 +24870,7 @@ bool LuaCEmbedTable_get_bool_by_index(LuaCEmbedTable *self, int index){
2486924870

2487024871
int LuaCEmbedTable_get_type_prop(LuaCEmbedTable *self, const char *name){
2487124872
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
24872-
lua_settop(self->main_object->state,0);
24873-
2487424873
private_lua_cembed_memory_limit = self->main_object->memory_limit;
24875-
2487624874
lua_getglobal(self->main_object->state,self->global_name);
2487724875
privateLuaCEmbd_get_field_protected(self->main_object,name);
2487824876
return lua_type(self->main_object->state,-1);
@@ -24881,7 +24879,6 @@ int LuaCEmbedTable_get_type_prop(LuaCEmbedTable *self, const char *name){
2488124879

2488224880
char* LuaCembedTable_get_string_prop(LuaCEmbedTable *self , const char *name){
2488324881
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NULL
24884-
lua_settop(self->main_object->state,0);
2488524882

2488624883
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2488724884

@@ -24900,7 +24897,6 @@ char* LuaCembedTable_get_string_prop(LuaCEmbedTable *self , const char *name){
2490024897

2490124898
long long LuaCembedTable_get_long_prop(LuaCEmbedTable *self , const char *name){
2490224899
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
24903-
lua_settop(self->main_object->state,0);
2490424900

2490524901
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2490624902
lua_getglobal(self->main_object->state,self->global_name);
@@ -24915,7 +24911,6 @@ long long LuaCembedTable_get_long_prop(LuaCEmbedTable *self , const char *name
2491524911

2491624912
double LuaCembedTable_get_double_prop(LuaCEmbedTable *self , const char *name){
2491724913
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
24918-
lua_settop(self->main_object->state,0);
2491924914

2492024915
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2492124916

@@ -24933,7 +24928,6 @@ double LuaCembedTable_get_double_prop(LuaCEmbedTable *self , const char *name){
2493324928

2493424929
bool LuaCembedTable_get_bool_prop(LuaCEmbedTable *self , const char *name){
2493524930
PRIVATE_LUA_CEMBED_TABLE_PROTECT_BOOL
24936-
lua_settop(self->main_object->state,0);
2493724931

2493824932
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2493924933

@@ -26125,6 +26119,11 @@ int privateLuaCEmbed_main_callback_handler(lua_State *L){
2612526119

2612626120
if(self->field_protection){
2612726121
private_LuaCEmbedResponse_free(possible_return);
26122+
if(self->error_msg){
26123+
free(self->error_msg);
26124+
self->error_msg = NULL;
26125+
}
26126+
2612826127
return PRIVATE_LUACEMBED_NO_RETURN;
2612926128
}
2613026129

src/LuaCEmbed/basic/basic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ void privata_LuaCEmbed_decrement_stack(LuaCEmbed *self){
111111
}
112112

113113
void privateLuaCEmbd_get_field_protected(LuaCEmbed *self,const char *name){
114+
bool old_field_proection = self->field_protection;
114115
self->field_protection = true;
115116
lua_getfield(self->state,-1,name);
116-
self->field_protection = false;
117+
self->field_protection = old_field_proection;
117118
}
118119

119120
void LuaCEmbed_free(LuaCEmbed *self){

src/LuaCEmbed/callback_handle/callback_handle.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ int privateLuaCEmbed_main_callback_handler(lua_State *L){
5858

5959
if(self->field_protection){
6060
private_LuaCEmbedResponse_free(possible_return);
61+
if(self->error_msg){
62+
free(self->error_msg);
63+
self->error_msg = NULL;
64+
}
65+
6166
return PRIVATE_LUACEMBED_NO_RETURN;
6267
}
6368

src/LuaCEmbed/table/table/getters/keys/keys.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11

22
int LuaCEmbedTable_get_type_prop(LuaCEmbedTable *self, const char *name){
33
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
4-
lua_settop(self->main_object->state,0);
5-
64
private_lua_cembed_memory_limit = self->main_object->memory_limit;
7-
85
lua_getglobal(self->main_object->state,self->global_name);
96
privateLuaCEmbd_get_field_protected(self->main_object,name);
107
return lua_type(self->main_object->state,-1);
@@ -13,7 +10,6 @@ int LuaCEmbedTable_get_type_prop(LuaCEmbedTable *self, const char *name){
1310

1411
char* LuaCembedTable_get_string_prop(LuaCEmbedTable *self , const char *name){
1512
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NULL
16-
lua_settop(self->main_object->state,0);
1713

1814
private_lua_cembed_memory_limit = self->main_object->memory_limit;
1915

@@ -32,7 +28,6 @@ char* LuaCembedTable_get_string_prop(LuaCEmbedTable *self , const char *name){
3228

3329
long long LuaCembedTable_get_long_prop(LuaCEmbedTable *self , const char *name){
3430
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
35-
lua_settop(self->main_object->state,0);
3631

3732
private_lua_cembed_memory_limit = self->main_object->memory_limit;
3833
lua_getglobal(self->main_object->state,self->global_name);
@@ -47,7 +42,6 @@ long long LuaCembedTable_get_long_prop(LuaCEmbedTable *self , const char *name
4742

4843
double LuaCembedTable_get_double_prop(LuaCEmbedTable *self , const char *name){
4944
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
50-
lua_settop(self->main_object->state,0);
5145

5246
private_lua_cembed_memory_limit = self->main_object->memory_limit;
5347

@@ -65,7 +59,6 @@ double LuaCembedTable_get_double_prop(LuaCEmbedTable *self , const char *name){
6559

6660
bool LuaCembedTable_get_bool_prop(LuaCEmbedTable *self , const char *name){
6761
PRIVATE_LUA_CEMBED_TABLE_PROTECT_BOOL
68-
lua_settop(self->main_object->state,0);
6962

7063
private_lua_cembed_memory_limit = self->main_object->memory_limit;
7164

tests/LuaCEmbed.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24120,9 +24120,10 @@ void privata_LuaCEmbed_decrement_stack(LuaCEmbed *self){
2412024120
}
2412124121

2412224122
void privateLuaCEmbd_get_field_protected(LuaCEmbed *self,const char *name){
24123+
bool old_field_proection = self->field_protection;
2412324124
self->field_protection = true;
2412424125
lua_getfield(self->state,-1,name);
24125-
self->field_protection = false;
24126+
self->field_protection = old_field_proection;
2412624127
}
2412724128

2412824129
void LuaCEmbed_free(LuaCEmbed *self){
@@ -24869,10 +24870,7 @@ bool LuaCEmbedTable_get_bool_by_index(LuaCEmbedTable *self, int index){
2486924870

2487024871
int LuaCEmbedTable_get_type_prop(LuaCEmbedTable *self, const char *name){
2487124872
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
24872-
lua_settop(self->main_object->state,0);
24873-
2487424873
private_lua_cembed_memory_limit = self->main_object->memory_limit;
24875-
2487624874
lua_getglobal(self->main_object->state,self->global_name);
2487724875
privateLuaCEmbd_get_field_protected(self->main_object,name);
2487824876
return lua_type(self->main_object->state,-1);
@@ -24881,7 +24879,6 @@ int LuaCEmbedTable_get_type_prop(LuaCEmbedTable *self, const char *name){
2488124879

2488224880
char* LuaCembedTable_get_string_prop(LuaCEmbedTable *self , const char *name){
2488324881
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NULL
24884-
lua_settop(self->main_object->state,0);
2488524882

2488624883
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2488724884

@@ -24900,7 +24897,6 @@ char* LuaCembedTable_get_string_prop(LuaCEmbedTable *self , const char *name){
2490024897

2490124898
long long LuaCembedTable_get_long_prop(LuaCEmbedTable *self , const char *name){
2490224899
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
24903-
lua_settop(self->main_object->state,0);
2490424900

2490524901
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2490624902
lua_getglobal(self->main_object->state,self->global_name);
@@ -24915,7 +24911,6 @@ long long LuaCembedTable_get_long_prop(LuaCEmbedTable *self , const char *name
2491524911

2491624912
double LuaCembedTable_get_double_prop(LuaCEmbedTable *self , const char *name){
2491724913
PRIVATE_LUA_CEMBED_TABLE_PROTECT_NUM
24918-
lua_settop(self->main_object->state,0);
2491924914

2492024915
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2492124916

@@ -24933,7 +24928,6 @@ double LuaCembedTable_get_double_prop(LuaCEmbedTable *self , const char *name){
2493324928

2493424929
bool LuaCembedTable_get_bool_prop(LuaCEmbedTable *self , const char *name){
2493524930
PRIVATE_LUA_CEMBED_TABLE_PROTECT_BOOL
24936-
lua_settop(self->main_object->state,0);
2493724931

2493824932
private_lua_cembed_memory_limit = self->main_object->memory_limit;
2493924933

@@ -26125,6 +26119,11 @@ int privateLuaCEmbed_main_callback_handler(lua_State *L){
2612526119

2612626120
if(self->field_protection){
2612726121
private_LuaCEmbedResponse_free(possible_return);
26122+
if(self->error_msg){
26123+
free(self->error_msg);
26124+
self->error_msg = NULL;
26125+
}
26126+
2612826127
return PRIVATE_LUACEMBED_NO_RETURN;
2612926128
}
2613026129

0 commit comments

Comments
 (0)