Decoders failing to allocate their buffer will cause a Lua error instead of crashing.

This commit is contained in:
slime
2022-08-25 19:44:10 -03:00
parent db1bf4707c
commit bded15ff2a
+8 -1
View File
@@ -39,7 +39,14 @@ Decoder::Decoder(Stream *stream, int bufferSize)
if (!stream->isReadable() || !stream->isSeekable())
throw love::Exception("Decoder input stream must be readable and seekable.");
buffer = new char[bufferSize];
try
{
buffer = new char[bufferSize];
}
catch (std::exception &)
{
throw love::Exception("Out of memory.");
}
}
Decoder::~Decoder()