From 9b8c5f642f51465663dae13c90d719e62517cb3c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 Jun 2024 17:24:49 -0400 Subject: [PATCH] testaudio: Better fix for NULL dereference. This code already handled NULL fine, it just got wrapped in a SDL_strdup call in e23257307e220c7dd3d827e195f52adaabaaeeeb, so make that SDL_strdup check for NULL first. --- test/testaudio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/testaudio.c b/test/testaudio.c index f32ea28f70..9f8d561e66 100644 --- a/test/testaudio.c +++ b/test/testaudio.c @@ -984,12 +984,9 @@ static Thing *CreatePhysicalDeviceThing(const SDL_AudioDeviceID which, const SDL thing = CreateThing(recording ? THING_PHYSDEV_RECORDING : THING_PHYSDEV, next_physdev_x, 170, 5, -1, -1, physdev_texture, NULL); if (thing) { const char *name = SDL_GetAudioDeviceName(which); - if (!name) { - name = "[Unnamed device]"; - } thing->data.physdev.devid = which; thing->data.physdev.recording = recording; - thing->data.physdev.name = SDL_strdup(name); + thing->data.physdev.name = name ? SDL_strdup(name) : NULL; thing->ondrag = DeviceThing_ondrag; thing->ondrop = PhysicalDeviceThing_ondrop; thing->ontick = PhysicalDeviceThing_ontick;