Plug leaks until Information Center, detected by the LeakSanitizer (#764)
Some checks are pending
CI / clang-format (push) Waiting to run
CI / ${{ matrix.name }} (false, --toolchain /usr/local/vitasdk/share/vita.toolchain.cmake, false, false, Ninja, Vita, ubuntu-latest, true, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.26100.0, false, false, Visual Studio 17 2022, true, Xbox One, windows-latest, amd64, false, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/3DS.cmake, false, devkitpro/devkitarm:latest, false, Ninja, true, Nintendo 3DS, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Switch.cmake, false, devkitpro/devkita64:latest, false, Ninja, Nintendo Switch, true, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, emcmake, false, false, true, Ninja, Emscripten, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, false, Ninja, true, MSVC (arm64), windows-latest, amd64_arm64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, false, true, Ninja, true, MSVC (x86), windows-latest, amd64_x86, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, false, Ninja, true, MSVC (x64), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (false, true, true, false, Ninja, true, MSVC (x64 Debug), windows-latest, amd64, false) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, -DCMAKE_SYSTEM_NAME=iOS, false, false, Xcode, true, iOS, macos-15, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, Ninja, true, mingw-w64-i686, mingw32, msys2 mingw32, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, false, false, Ninja, Android, ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, false, true, false, Ninja, macOS, macos-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, false, Ninja, true, mingw-w64-x86_64, mingw64, msys2 mingw64, windows-latest, msys2 {0}, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux (Debug), ubuntu-latest, true) (push) Waiting to run
CI / ${{ matrix.name }} (true, true, true, false, Ninja, true, Linux, ubuntu-latest, true) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (aarch64, ubuntu-22.04-arm) (push) Waiting to run
CI / Flatpak (${{ matrix.arch }}) (x86_64, ubuntu-latest) (push) Waiting to run
CI / C++ (push) Waiting to run
CI / Release (push) Blocked by required conditions
Docker / Publish web port (push) Waiting to run

This commit is contained in:
Anonymous Maarten 2026-01-04 03:35:42 +01:00 committed by GitHub
parent 945d868644
commit e4690a57b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 90 additions and 25 deletions

View File

@ -483,6 +483,7 @@ SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event)
if (device && !device->ConvertEventToRenderCoordinates(event)) {
SDL_Log("Failed to convert event coordinates: %s", SDL_GetError());
}
device->Release();
#ifdef __EMSCRIPTEN__
Emscripten_ConvertEventToRenderCoordinates(event);

View File

@ -155,6 +155,11 @@ void LegoOmni::Destroy()
m_transitionManager = NULL;
}
if (m_videoManager) {
delete m_videoManager;
m_videoManager = NULL;
}
m_action.ClearAtom();
DestroyScripts();

View File

@ -54,6 +54,8 @@ LegoVideoManager::LegoVideoManager()
m_unk0xe5 = FALSE;
m_unk0x554 = FALSE;
m_paused = FALSE;
m_camera = NULL;
m_appdata = NULL;
}
// FUNCTION: LEGO1 0x1007ab40
@ -237,6 +239,11 @@ MxResult LegoVideoManager::Create(MxVideoParam& p_videoParam, MxU32 p_frequencyM
// FUNCTION: BETA10 0x100d6816
void LegoVideoManager::Destroy()
{
if (m_camera != NULL) {
m_camera->Release();
m_camera = NULL;
}
if (m_cursorSurface != NULL) {
m_cursorSurface->Release();
m_cursorSurface = NULL;
@ -264,6 +271,12 @@ void LegoVideoManager::Destroy()
delete m_3dManager;
MxVideoManager::Destroy();
if (m_direct3d != NULL) {
delete m_direct3d;
m_direct3d = NULL;
}
delete m_phonemeRefList;
delete m_stopWatch;
}
@ -677,6 +690,7 @@ int LegoVideoManager::EnableRMDevice()
d3drmDev2->SetDither(m_dither);
d3drmDev2->SetBufferCount(m_bufferCount);
m_camera->Release();
m_camera = nullptr;
if (viewport->AddDestroyCallback(ViewportDestroyCallback, m_appdata) == D3DRM_OK) {
((TglImpl::ViewImpl*) m_3dManager->GetLego3DView()->GetView())->SetImplementationData(viewport);

View File

@ -57,19 +57,21 @@ BOOL LegoView::Create(const TglSurface::CreateStruct& rCreateStruct, Tgl::Render
viewAngle = 90;
}
assert(!m_pScene);
m_pScene = pRenderer->CreateGroup();
assert(m_pScene);
// TglSurface::Create() calls CreateView(), and we need the camera in
// CreateView(), so create camera before calling TglSurface::Create()
assert(!m_pCamera);
m_pCamera = pRenderer->CreateCamera();
assert(m_pCamera);
if (!TglSurface::Create(rCreateStruct, pRenderer, m_pScene)) {
delete m_pScene;
m_pScene = 0;
m_pScene = NULL;
delete m_pCamera;
m_pCamera = 0;
m_pCamera = NULL;
return FALSE;
}
@ -96,10 +98,10 @@ Tgl::View* LegoView::CreateView(Tgl::Renderer* pRenderer, Tgl::Device* pDevice)
void LegoView::Destroy()
{
delete m_pScene;
m_pScene = 0;
m_pScene = NULL;
delete m_pCamera;
m_pCamera = 0;
m_pCamera = NULL;
TglSurface::Destroy();
}

View File

@ -86,6 +86,9 @@ BOOL TglSurface::Create(const CreateStruct& rCreateStruct, Renderer* pRenderer,
int textureColorCount = -1;
Result result;
assert(!m_pRenderer);
assert(!m_pScene);
assert(!m_pDevice);
m_pRenderer = pRenderer;
m_pScene = pScene;
m_pDevice = m_pRenderer->CreateDevice(createData);
@ -145,6 +148,7 @@ BOOL TglSurface::Create(const CreateStruct& rCreateStruct, Renderer* pRenderer,
m_width = m_pDevice->GetWidth();
m_height = m_pDevice->GetHeight();
assert(!m_pView);
m_pView = CreateView(m_pRenderer, m_pDevice);
if (!m_pView) {
delete m_pDevice;

View File

@ -139,6 +139,7 @@ BOOL MxDirect3D::D3DCreate()
Error("Creation of IDirect3D failed", result);
return FALSE;
}
m_pDirect3d->Release();
return TRUE;
}
@ -181,6 +182,7 @@ BOOL MxDirect3D::D3DSetMode()
}
LPDIRECTDRAWSURFACE backBuf = BackBuffer();
assert(!m_pDirect3dDevice);
HRESULT result = m_pDirect3d->CreateDevice(m_currentDeviceInfo->m_guid, backBuf, &m_pDirect3dDevice);
if (result != DD_OK) {

View File

@ -275,6 +275,10 @@ BOOL MxDeviceEnumerate::EnumDirectDrawCallback(LPGUID p_guid, LPSTR p_driverDesc
}
done:
if (miniwind3d) {
miniwind3d->Release();
}
if (lpDirect3d2) {
lpDirect3d2->Release();
}

View File

@ -57,10 +57,10 @@ class MxMediaPresenter : public MxPresenter {
// MxMediaPresenter::`scalar deleting destructor'
protected:
MxDSSubscriber* m_subscriber; // 0x40
MxStreamChunkList* m_loopingChunks; // 0x44
MxStreamChunkListCursor* m_loopingChunkCursor; // 0x48
MxStreamChunk* m_currentChunk; // 0x4c
MxDSSubscriber* m_subscriber = NULL; // 0x40
MxStreamChunkList* m_loopingChunks = NULL; // 0x44
MxStreamChunkListCursor* m_loopingChunkCursor = NULL; // 0x48
MxStreamChunk* m_currentChunk = NULL; // 0x4c
void Init();
void Destroy(MxBool p_fromDestructor);

View File

@ -13,13 +13,13 @@ void MxSoundPresenter::Destroy(MxBool p_fromDestructor)
MSoundManager()->UnregisterPresenter(*this);
}
ENTER(m_criticalSection);
MxMediaPresenter::Init();
m_criticalSection.Leave();
if (!p_fromDestructor) {
MxMediaPresenter::Destroy(FALSE);
}
ENTER(m_criticalSection);
MxMediaPresenter::Init();
m_criticalSection.Leave();
}
// FUNCTION: LEGO1 0x100b1aa0

View File

@ -16,6 +16,12 @@ DECOMP_SIZE_ASSERT(MxStreamChunkListCursor, 0x10);
// FUNCTION: LEGO1 0x100b54e0
void MxMediaPresenter::Init()
{
if (this->m_loopingChunks) {
delete m_loopingChunks;
}
if (this->m_loopingChunkCursor) {
delete this->m_loopingChunkCursor;
}
this->m_subscriber = NULL;
this->m_loopingChunks = NULL;
this->m_loopingChunkCursor = NULL;
@ -38,6 +44,7 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
if (m_loopingChunkCursor) {
delete m_loopingChunkCursor;
m_loopingChunkCursor = NULL;
}
if (m_loopingChunks) {
@ -49,6 +56,7 @@ void MxMediaPresenter::Destroy(MxBool p_fromDestructor)
}
delete m_loopingChunks;
m_loopingChunks = NULL;
}
Init();
@ -106,6 +114,12 @@ MxResult MxMediaPresenter::StartAction(MxStreamController* p_controller, MxDSAct
if (MxPresenter::StartAction(p_controller, p_action) == SUCCESS) {
if (m_action->GetFlags() & MxDSAction::c_looping) {
if (m_loopingChunks) {
delete m_loopingChunks;
}
if (m_loopingChunkCursor) {
delete m_loopingChunkCursor;
}
m_loopingChunks = new MxStreamChunkList;
m_loopingChunkCursor = new MxStreamChunkListCursor(m_loopingChunks);

View File

@ -54,10 +54,8 @@ ViewportAppData::~ViewportAppData()
}
refCount = pChildFrames->Release();
assert(refCount == 0);
refCount = m_pLightFrame->Release();
assert(refCount == 0);
}
// Forward declare to satisfy order check

View File

@ -545,11 +545,11 @@ ViewROI* ViewManager::Pick(Tgl::View* p_view, int x, int y)
}
}
}
visual->Release();
frameArray->Release();
}
}
visual->Release();
frameArray->Release();
}
picked->Release();

View File

@ -7,6 +7,7 @@
#include "miniwin.h"
#include <SDL3/SDL.h>
#include <cassert>
#include <cmath>
#include <cstddef>
@ -349,6 +350,7 @@ Direct3DRMSDL3GPURenderer::Direct3DRMSDL3GPURenderer(
Direct3DRMSDL3GPURenderer::~Direct3DRMSDL3GPURenderer()
{
assert(m_refCount == 0);
SDL_ReleaseGPUBuffer(m_device, m_uiMeshCache.vertexBuffer);
SDL_ReleaseGPUBuffer(m_device, m_uiMeshCache.indexBuffer);
SDL_ReleaseWindowFromGPUDevice(m_device, DDWindow);
@ -717,6 +719,9 @@ SDL_GPUTransferBuffer* Direct3DRMSDL3GPURenderer::GetUploadBuffer(size_t size)
void Direct3DRMSDL3GPURenderer::StartRenderPass(float r, float g, float b, bool clear)
{
if (m_cmdbuf != nullptr) {
SDL_CancelGPUCommandBuffer(m_cmdbuf);
}
m_cmdbuf = SDL_AcquireGPUCommandBuffer(m_device);
if (!m_cmdbuf) {
SDL_LogError(

View File

@ -9,10 +9,12 @@
#include "miniwin/miniwindevice.h"
#include <SDL3/SDL.h>
#include <cassert>
Direct3DRMDevice2Impl::Direct3DRMDevice2Impl(DWORD width, DWORD height, Direct3DRMRenderer* renderer)
: m_virtualWidth(width), m_virtualHeight(height), m_renderer(renderer), m_viewports(new Direct3DRMViewportArrayImpl)
{
m_renderer->AddRef();
Resize();
}
@ -25,7 +27,7 @@ Direct3DRMDevice2Impl::~Direct3DRMDevice2Impl()
viewport->Release();
}
m_viewports->Release();
delete m_renderer;
m_renderer->Release();
}
HRESULT Direct3DRMDevice2Impl::QueryInterface(const GUID& riid, void** ppvObject)
@ -161,7 +163,9 @@ void Direct3DRMDevice2Impl::Resize()
for (int i = 0; i < m_viewports->GetSize(); i++) {
IDirect3DRMViewport* viewport;
m_viewports->GetElement(i, &viewport);
assert(viewport);
static_cast<Direct3DRMViewportImpl*>(viewport)->UpdateProjectionMatrix();
viewport->Release();
}
}

View File

@ -10,11 +10,8 @@
Direct3DRMFrameImpl::Direct3DRMFrameImpl(Direct3DRMFrameImpl* parent)
{
m_children = new Direct3DRMFrameArrayImpl;
m_children->AddRef();
m_lights = new Direct3DRMLightArrayImpl;
m_lights->AddRef();
m_visuals = new Direct3DRMVisualArrayImpl;
m_visuals->AddRef();
if (parent) {
parent->AddChild(this);
}

View File

@ -176,6 +176,9 @@ HRESULT Direct3DRMMeshImpl::SetGroupTexture(D3DRMGROUPINDEX groupIndex, IDirect3
}
texture->AddRef();
if (group.texture) {
group.texture->Release();
}
group.texture = texture;
group.version++;
return DD_OK;

View File

@ -19,6 +19,14 @@ Direct3DRMViewportImpl::Direct3DRMViewportImpl(DWORD width, DWORD height, Direct
{
}
Direct3DRMViewportImpl::~Direct3DRMViewportImpl()
{
if (m_camera) {
m_camera->Release();
m_camera = nullptr;
}
}
static void D3DRMMatrixMultiply(D3DRMMATRIX4D out, const D3DRMMATRIX4D a, const D3DRMMATRIX4D b)
{
for (int i = 0; i < 4; ++i) {
@ -374,12 +382,12 @@ HRESULT Direct3DRMViewportImpl::Clear()
HRESULT Direct3DRMViewportImpl::SetCamera(IDirect3DRMFrame* camera)
{
if (m_camera) {
m_camera->Release();
}
if (camera) {
camera->AddRef();
}
if (m_camera) {
m_camera->Release();
}
m_camera = camera;
return DD_OK;
}

View File

@ -131,7 +131,7 @@ inline static void Direct3DRMSDL3GPU_EnumDevice(LPD3DENUMDEVICESCALLBACK cb, voi
if (!device) {
return;
}
delete device;
device->Release();
#endif
D3DDEVICEDESC halDesc = {};

View File

@ -21,6 +21,7 @@ class Direct3DRMFrameImpl;
struct Direct3DRMViewportImpl : public Direct3DRMObjectBaseImpl<IDirect3DRMViewport> {
Direct3DRMViewportImpl(DWORD width, DWORD height, Direct3DRMRenderer* renderer);
~Direct3DRMViewportImpl() override;
HRESULT Render(IDirect3DRMFrame* group) override;
/**
* @brief Blit the render back to our backbuffer

View File

@ -2,16 +2,19 @@
#include "miniwin/ddraw.h"
#include <SDL3/SDL.h>
#include <cassert>
#include <vector>
ULONG IUnknown::AddRef()
{
assert(m_refCount > 0);
m_refCount += 1;
return m_refCount;
}
ULONG IUnknown::Release()
{
assert(m_refCount > 0);
m_refCount -= 1;
if (m_refCount == 0) {
delete this;