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:
Bart van Strien
2019-08-11 11:13:22 +02:00
parent 639bdb10e9
commit cb625d890a
2 changed files with 4 additions and 2 deletions
+3 -2
View File
@@ -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))
{