SkPaint::getTypeface() can return NULL; paint:getTypeface() would
attempt to refcount that value before storing it on the Lua stack
and crash. This is a minimal workaround that fixes the crash.
R=reed@google.com, tomhudson@google.com, robertphillips@google.com
Author: tomhudson@chromium.org
Review URL: https://codereview.chromium.org/
109793010
git-svn-id: http://skia.googlecode.com/svn/trunk@12706
2bbb7eff-a529-9590-31e7-
b0007b416f81
}
template <typename T> void push_ref(lua_State* L, T* ref) {
- *(T**)lua_newuserdata(L, sizeof(T*)) = SkRef(ref);
+ *(T**)lua_newuserdata(L, sizeof(T*)) = SkSafeRef(ref);
luaL_getmetatable(L, get_mtname<T>());
lua_setmetatable(L, -2);
}
///////////////////////////////////////////////////////////////////////////////
static int ltypeface_gc(lua_State* L) {
- get_ref<SkTypeface>(L, 1)->unref();
+ SkSafeUnref(get_ref<SkTypeface>(L, 1));
return 0;
}