From 56ff59f73fbd95d07794f7c254d9c6e34c7409f1 Mon Sep 17 00:00:00 2001 From: Louis <35883445+louist103@users.noreply.github.com> Date: Thu, 21 Nov 2024 22:57:05 -0500 Subject: [PATCH] Fix memory freeing issue on Windows --- utils/filebox.h | 2 +- windows/CustomStreamedAudio.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/filebox.h b/utils/filebox.h index d5709ff..112b905 100644 --- a/utils/filebox.h +++ b/utils/filebox.h @@ -67,7 +67,7 @@ static void FillFileQueue(T& dest, char* mBasePath, ExtCheckCallback cb) { size_t s2 = strlen(mBasePath); size_t sizeToAlloc = s1 + s2 + 2; - char* fullPath = (char*)operator new(sizeToAlloc, std::align_val_t(2)); + char* fullPath = (char*)operator new[](sizeToAlloc, std::align_val_t(2)); snprintf(fullPath, sizeToAlloc, "%s\\%s", mBasePath, ffd.cFileName); dest.push_back(fullPath); } diff --git a/windows/CustomStreamedAudio.cpp b/windows/CustomStreamedAudio.cpp index e58813f..bb4e5c3 100644 --- a/windows/CustomStreamedAudio.cpp +++ b/windows/CustomStreamedAudio.cpp @@ -38,8 +38,8 @@ CustomStreamedAudioWindow::CustomStreamedAudioWindow() { static void ClearFileQueue(std::vector* fileQueue) { for (auto f : *fileQueue) { // The lowest bit of the path is set to 1 if the file has been processed. We need to undo that to delete it. - uintptr_t origPtr = (uintptr_t)f & (UINTPTR_MAX & (~1)); - operator delete[]((char*)(origPtr)); + uintptr_t origPtr = (uintptr_t)f & (UINTPTR_MAX & (~(uintptr_t)1)); + operator delete[]((void*)origPtr, std::align_val_t(2)); } fileQueue->clear(); }