From 0f2878e9c46383800375f6fb71a9398a95ec3cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaarlo=20R=C3=A4ih=C3=A4?= Date: Tue, 12 Nov 2024 20:02:54 +0200 Subject: [PATCH] Add some safety checks Because all kind of streams are allowed --- src/QOA.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/QOA.cs b/src/QOA.cs index bf0e8ed..f0ef684 100644 --- a/src/QOA.cs +++ b/src/QOA.cs @@ -516,6 +516,16 @@ public short[] qoa_decode(Stream inputStream, out QOA_Desc qoa) /// Output stream (WAV) public void DecodeToWav(Stream inputStream, Stream outputSteam) { + if (!inputStream.CanRead) + { + throw new IOException("Input stream must be readable!"); + } + + if (!outputSteam.CanWrite) + { + throw new IOException("Output stream must be writable!"); + } + short[] sampleData = qoa_decode(inputStream, out QOA_Desc qoa); WriteWav(outputSteam, sampleData, qoa); }