Fix Little Memory Leak Risk

This commit is contained in:
copecone committed 2026-06-01 12:35:26 +09:00
1 parent 6bd4a8975e
commit bc7a7eca75
3 files changed
+47 -11

No files matched your search

+10 -5
View File
@@ -1,5 +1,6 @@
using System;
using System.IO;
using MelonLoader;
namespace ADOFAIRenderer.Util
{
@@ -13,11 +14,15 @@ namespace ADOFAIRenderer.Util
unsafe
{
// Create an unmanaged memory stream that wraps the native pointer
// (This does not allocate new memory; it references the existing pointer)
using var unmanagedStream = new UnmanagedMemoryStream((byte*)nativePtr, length);
// Copy the data directly into your target stream
unmanagedStream.CopyTo(destinationStream);
try
{
var span = new ReadOnlySpan<byte>((void*)nativePtr, length);
destinationStream.Write(span);
}
catch (IOException err)
{
Melon<RenderMod>.Logger.Error($"FFmpeg 파이프가 예상치 못하게 닫혔습니다: {err.Message}");
}
}
}
}