libavdevice/alsa.c: fix NULL pointer dereference

This commit is contained in:
Romain Beauxis
2026-04-18 09:14:50 -05:00
committed by toots
parent 415b466d41
commit 82d7e375f1
2 changed files with 12 additions and 2 deletions

View File

@@ -383,8 +383,10 @@ int ff_alsa_get_device_list(AVDeviceInfoList *device_list, snd_pcm_stream_t stre
ret = AVERROR(ENOMEM);
goto fail;
}
new_device->device_name = av_strdup(name);
if ((tmp = strrchr(descr, '\n')) && tmp[1])
new_device->device_name = av_strdup(name ? name : "");
if (!descr)
new_device->device_description = av_strdup("");
else if ((tmp = strrchr(descr, '\n')) && tmp[1])
new_device->device_description = av_strdup(&tmp[1]);
else
new_device->device_description = av_strdup(descr);

View File

@@ -2,5 +2,13 @@ FATE_LIBAVDEVICE-$(CONFIG_JACK_INDEV) += fate-timefilter
fate-timefilter: libavdevice/tests/timefilter$(EXESUF)
fate-timefilter: CMD = run libavdevice/tests/timefilter
tests/data/alsa_nodesc.conf: | tests/data
$(Q)printf 'pcm.nodesc {\n\ttype null\n\thint {\n\t\tshow on\n\t}\n}\n' > $@
FATE_FFMPEG-$(CONFIG_ALSA_INDEV) += fate-alsa-device-list-nodesc
fate-alsa-device-list-nodesc: tests/data/alsa_nodesc.conf
fate-alsa-device-list-nodesc: CMD = (export ALSA_CONFIG_PATH=$(TARGET_PATH)/tests/data/alsa_nodesc.conf && ffmpeg -sources alsa)
fate-alsa-device-list-nodesc: CMP = null
FATE-$(CONFIG_AVDEVICE) += $(FATE_LIBAVDEVICE-yes)
fate-libavdevice: $(FATE_LIBAVDEVICE-yes)