mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Fix usage of a string past its lifetime, and set a default type for encode
This commit is contained in:
@@ -149,16 +149,18 @@ namespace image
|
|||||||
if (lua_isstring(L, 2))
|
if (lua_isstring(L, 2))
|
||||||
luax_convobj(L, 2, "filesystem", "newFile");
|
luax_convobj(L, 2, "filesystem", "newFile");
|
||||||
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T);
|
love::filesystem::File * file = luax_checktype<love::filesystem::File>(L, 2, "File", FILESYSTEM_FILE_T);
|
||||||
|
std::string ext;
|
||||||
const char * fmt;
|
const char * fmt;
|
||||||
if (lua_isnoneornil(L, 3))
|
if (lua_isnoneornil(L, 3))
|
||||||
{
|
{
|
||||||
fmt = file->getExtension().c_str();
|
ext = file->getExtension();
|
||||||
|
fmt = ext.c_str();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fmt = luaL_checkstring(L, 3);
|
fmt = luaL_checkstring(L, 3);
|
||||||
}
|
}
|
||||||
ImageData::Format format;
|
ImageData::Format format = ImageData::FORMAT_PNG;
|
||||||
ImageData::getConstant(fmt, format);
|
ImageData::getConstant(fmt, format);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user