mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Make sure luax_getfile always returns a retained value
Before it would return a retained value if it returned a freshly constructed file, and an unretained value otherwise. Also update all (3) call sites, to correctly retain or release as needed.
This commit is contained in:
@@ -214,7 +214,10 @@ File *luax_getfile(lua_State *L, int idx)
|
||||
file = instance()->newFile(filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
file = luax_checkfile(L, idx);
|
||||
file->retain();
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
@@ -227,7 +230,6 @@ FileData *luax_getfiledata(lua_State *L, int idx)
|
||||
if (lua_isstring(L, idx) || luax_istype(L, idx, File::type))
|
||||
{
|
||||
file = luax_getfile(L, idx);
|
||||
file->retain();
|
||||
}
|
||||
else if (luax_istype(L, idx, FileData::type))
|
||||
{
|
||||
@@ -260,7 +262,6 @@ Data *luax_getdata(lua_State *L, int idx)
|
||||
if (lua_isstring(L, idx) || luax_istype(L, idx, File::type))
|
||||
{
|
||||
file = luax_getfile(L, idx);
|
||||
file->retain();
|
||||
}
|
||||
else if (luax_istype(L, idx, Data::type))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user