mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +00:00
LibAudio: Handle stream errors in FlacLoader
The FlacLoader already has numerous checks for invalid data reads and for invalid stream states, but it never actually handles the stream errors on the stream object. By handling them properly we can actually run FuzzFlacLoader for longer than a few seconds before it hits the first assertion :^).
This commit is contained in:
parent
9c3e6f3f63
commit
845d403b8c
2 changed files with 48 additions and 9 deletions
|
@ -22,11 +22,26 @@ class FlacInputStream : public Variant<Core::InputFileStream, InputMemoryStream>
|
|||
public:
|
||||
using Variant<Core::InputFileStream, InputMemoryStream>::Variant;
|
||||
|
||||
void seek(size_t pos)
|
||||
bool seek(size_t pos)
|
||||
{
|
||||
this->visit(
|
||||
[&](auto& stream) {
|
||||
return this->visit(
|
||||
[&](Core::InputFileStream& stream) {
|
||||
return stream.seek(pos);
|
||||
},
|
||||
[&](InputMemoryStream& stream) {
|
||||
if (pos >= stream.bytes().size()) {
|
||||
return false;
|
||||
}
|
||||
stream.seek(pos);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
bool handle_any_error()
|
||||
{
|
||||
return this->visit(
|
||||
[&](auto& stream) {
|
||||
return stream.handle_any_error();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -56,6 +71,11 @@ class FlacLoaderPlugin : public LoaderPlugin {
|
|||
public:
|
||||
FlacLoaderPlugin(const StringView& path);
|
||||
FlacLoaderPlugin(const ByteBuffer& buffer);
|
||||
~FlacLoaderPlugin()
|
||||
{
|
||||
if (m_stream)
|
||||
m_stream->handle_any_error();
|
||||
}
|
||||
|
||||
virtual bool sniff() override;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue