Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix leak issue

  • Loading branch information...
commit 6b08c0797190d79f89db1300ba80008852316f96 1 parent 29d0229
@mmin18 authored
View
4 README.md
@@ -8,7 +8,3 @@ The patch is a zip file contains patch.lua and other lua codes. The sample code
The sample iOS project loads the patch from a url (which you probably want to change in AppDelegate.m) before launch.
The Original.png and Patched.png shows the difference.
-### Issue
-The mutated version of wax leaks when call method directly from Obj-C!!!
-
-The issue is located at wax_instance.m, TODO mark.
View
3  WaxPatch/WaxPatch/wax/wax_gc.m
@@ -46,6 +46,9 @@ + (void)cleanupUnusedObject {
lua_pushvalue(L, -1);
lua_pushnil(L);
lua_rawset(L, -4); // Clear it!
+ if(instanceUserdata->waxRetain) {
+ [instanceUserdata->instance release];
+ }
}
}
View
1  WaxPatch/WaxPatch/wax/wax_instance.h
@@ -20,6 +20,7 @@ typedef struct _wax_instance_userdata {
BOOL isClass;
Class isSuper; // isSuper not only stores whether the class is a super, but it also contains the value of the next superClass.
BOOL actAsSuper; // It only acts like a super once, when it is called for the first time.
+ BOOL waxRetain; // retained by wax, release instance when wax_gc
} wax_instance_userdata;
int luaopen_wax_instance(lua_State *L);
View
6 WaxPatch/WaxPatch/wax/wax_instance.m
@@ -218,8 +218,10 @@ BOOL wax_instance_pushFunction(lua_State *L, id self, SEL selector) {
if (lua_isnil(L, -1)) {
// TODO:
// quick and dirty solution to let obj-c call directly into lua
- // cause a obj-c leak, should we release it later?
- wax_instance_create(L, self, NO);
+ // to avoid obj-c leak, we release instance when wax_gc
+ wax_instance_userdata *data = wax_instance_create(L, self, NO);
+ data->waxRetain = YES;
+// [self release];
// END_STACK_MODIFY(L, 0)
// return NO; // userdata doesn't exist
}
Please sign in to comment.
Something went wrong with that request. Please try again.