Fix refcounting in lovr.data;
@@ -14,9 +14,9 @@ int l_lovrDataInit(lua_State* L) {
int l_lovrDataNewTextureData(lua_State* L) {
Blob* blob = luax_readblob(L, 1, "Texture");
TextureData* textureData = lovrTextureDataFromBlob(blob);
+ luax_pushtype(L, TextureData, textureData);
lovrRelease(&blob->ref);
lovrRelease(&textureData->ref);
- luax_pushtype(L, TextureData, textureData);
return 1;
}
@@ -24,9 +24,9 @@ int l_lovrDataNewAudioStream(lua_State* L) {
Blob* blob = luax_readblob(L, 1, "Sound");
size_t bufferSize = luaL_optinteger(L, 2, 4096);
AudioStream* stream = lovrAudioStreamCreate(blob, bufferSize);
+ luax_pushtype(L, AudioStream, stream);
lovrRelease(&blob->ref);
lovrRelease(&stream->ref);
- luax_pushtype(L, AudioStream, stream);
return 1;
}
