diff options
author | Lukasz Marek <lukasz.m.luki@gmail.com> | 2014-03-04 02:57:27 +0100 |
---|---|---|
committer | Lukasz Marek <lukasz.m.luki@gmail.com> | 2014-03-06 00:34:50 +0100 |
commit | 2475fdbd047d8956b03f1bfb1e3f896985fd8c7f (patch) | |
tree | 0520e6b0768d9739e5c3c8b53cd4a9ae60c3646b | |
parent | 1aa262f460c0814e71619a66a9652af4692a468a (diff) | |
download | ffmpeg-2475fdbd047d8956b03f1bfb1e3f896985fd8c7f.tar.gz |
lavd/avdevice: always free detected devices on error
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
-rw-r--r-- | libavdevice/avdevice.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 8964b96f36..ea14c7a286 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -101,6 +101,7 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) { + int ret; av_assert0(s); av_assert0(device_list); av_assert0(s->oformat || s->iformat); @@ -113,8 +114,12 @@ int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) if (!(*device_list)) return AVERROR(ENOMEM); if (s->oformat) - return s->oformat->get_device_list(s, *device_list); - return s->iformat->get_device_list(s, *device_list); + ret = s->oformat->get_device_list(s, *device_list); + else + ret = s->iformat->get_device_list(s, *device_list); + if (ret < 0) + avdevice_free_list_devices(device_list); + return ret; } void avdevice_free_list_devices(AVDeviceInfoList **device_list) |