From db9d0b4403094b15782376308d6d261c6179f28c Mon Sep 17 00:00:00 2001 From: kunitoki Date: Tue, 3 Dec 2024 23:42:00 +0100 Subject: [PATCH] Fix undefined behaviour and memory issues --- tests/juce_core/juce_ReferenceCountedObject.cpp | 8 ++++---- tests/juce_core/juce_ZipFile.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/juce_core/juce_ReferenceCountedObject.cpp b/tests/juce_core/juce_ReferenceCountedObject.cpp index e8e1d2a3..c50d4b80 100644 --- a/tests/juce_core/juce_ReferenceCountedObject.cpp +++ b/tests/juce_core/juce_ReferenceCountedObject.cpp @@ -74,7 +74,7 @@ TEST (ReferenceCountedObjectTests, DecReferenceCountWithoutDeleting) EXPECT_TRUE (obj->decReferenceCountWithoutDeleting()); EXPECT_EQ (obj->getReferenceCount(), 0); - delete obj; + obj = nullptr; } TEST (ReferenceCountedObjectTests, DecConstReferenceCountWithoutDeleting) @@ -85,7 +85,7 @@ TEST (ReferenceCountedObjectTests, DecConstReferenceCountWithoutDeleting) EXPECT_TRUE (obj->decReferenceCountWithoutDeleting()); EXPECT_EQ (obj->getReferenceCount(), 0); - delete obj; + obj = nullptr; } // SingleThreadedReferenceCountedObject tests @@ -125,7 +125,7 @@ TEST (SingleThreadedReferenceCountedObjectTests, DecReferenceCountWithoutDeletin EXPECT_TRUE (obj->decReferenceCountWithoutDeleting()); EXPECT_EQ (obj->getReferenceCount(), 0); - delete obj; + obj = nullptr; } TEST (SingleThreadedReferenceCountedObjectTests, DecConstReferenceCountWithoutDeleting) @@ -136,7 +136,7 @@ TEST (SingleThreadedReferenceCountedObjectTests, DecConstReferenceCountWithoutDe EXPECT_TRUE (obj->decReferenceCountWithoutDeleting()); EXPECT_EQ (obj->getReferenceCount(), 0); - delete obj; + obj = nullptr; } // ReferenceCountedObjectPtr tests diff --git a/tests/juce_core/juce_ZipFile.cpp b/tests/juce_core/juce_ZipFile.cpp index b469d525..873f69ae 100644 --- a/tests/juce_core/juce_ZipFile.cpp +++ b/tests/juce_core/juce_ZipFile.cpp @@ -244,7 +244,7 @@ TEST_F (ZipFileTests, CreateStreamForEntryByName) ZipFile zip (zipFile); const ZipFile::ZipEntry* entry = zip.getEntry ("nonexistent.txt"); - EXPECT_EQ (zip.createStreamForEntry (*entry), nullptr); // Assumes the test.zip does not contain this file + ASSERT_EQ (nullptr, entry); } TEST_F (ZipFileTests, UncompressTo)