DOS & Tray: Don't do NULL-checks before SDL_free()

This commit is contained in:
Eddy Jansson
2026-05-13 18:05:39 +02:00
committed by Sam Lantinga
parent 3dbd3e43e2
commit 70159c34f6
4 changed files with 7 additions and 21 deletions

View File

@@ -485,12 +485,8 @@ static void DOSSOUNDBLASTER_CloseDevice(SDL_AudioDevice *device)
}
// Free ring buffer resources.
if (hidden->ring_buffer) {
SDL_free(hidden->ring_buffer);
}
if (hidden->staging_buffer) {
SDL_free(hidden->staging_buffer);
}
SDL_free(hidden->ring_buffer);
SDL_free(hidden->staging_buffer);
// Clear ISR-visible statics.
isr_ring_buffer = NULL;

View File

@@ -48,9 +48,7 @@ SDL_Mutex *SDL_CreateMutex(void)
void SDL_DestroyMutex(SDL_Mutex *mutex)
{
if (mutex) {
SDL_free(mutex);
}
SDL_free(mutex);
}
void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS

View File

@@ -44,9 +44,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value)
void SDL_DestroySemaphore(SDL_Semaphore *sem)
{
if (sem) {
SDL_free(sem);
}
SDL_free(sem);
}
bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)

View File

@@ -561,9 +561,7 @@ void DestroyMenu(SDL_TrayMenu *menu)
SDL_ListClear(&menu_dbus->menu);
}
if (menu_dbus->array_representation) {
SDL_free(menu_dbus->array_representation);
}
SDL_free(menu_dbus->array_representation);
SDL_free(menu_dbus);
SDL_free(menu);
@@ -656,9 +654,7 @@ void SetTrayTooltip(SDL_Tray *tray, const char *text)
driver = (SDL_TrayDriverDBus *)tray->driver->internal;
tray_dbus = (SDL_TrayDBus *)tray->internal;
if (tray_dbus->tooltip) {
SDL_free(tray_dbus->tooltip);
}
SDL_free(tray_dbus->tooltip);
if (text) {
tray_dbus->tooltip = SDL_strdup(text);
@@ -907,9 +903,7 @@ SDL_TrayEntry **GetTrayEntries(SDL_TrayMenu *menu, int *count)
menu_dbus = (SDL_TrayMenuDBus *)menu->internal;
if (menu_dbus->array_representation) {
SDL_free(menu_dbus->array_representation);
}
SDL_free(menu_dbus->array_representation);
sz = SDL_ListCountEntries(&menu_dbus->menu);
array_representation = SDL_calloc(sz + 1, sizeof(SDL_TrayEntry *));