summaryrefslogtreecommitdiff
path: root/libavdevice/avfoundation.m
diff options
context:
space:
mode:
authorZhao Zhili <quinkblack@foxmail.com>2022-02-05 00:19:34 +0800
committerThilo Borgmann <thilo.borgmann@mail.de>2022-02-22 13:02:02 +0100
commit6b708592fa8c80a8c65b063b25bb496920d1eda0 (patch)
tree219733b8343f2e394bace9cf80f46fe0696023c1 /libavdevice/avfoundation.m
parent17a59a634c39b00a680c6ebbaea58db95594d13d (diff)
downloadffmpeg-6b708592fa8c80a8c65b063b25bb496920d1eda0.tar.gz
avdevice/avfoundation: fix memleak
Diffstat (limited to 'libavdevice/avfoundation.m')
-rw-r--r--libavdevice/avfoundation.m10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavdevice/avfoundation.m b/libavdevice/avfoundation.m
index 0cd6e646d5..2078c4879c 100644
--- a/libavdevice/avfoundation.m
+++ b/libavdevice/avfoundation.m
@@ -106,6 +106,7 @@ typedef struct
int audio_device_index;
int audio_stream_index;
+ char *url;
char *video_filename;
char *audio_filename;
@@ -299,6 +300,7 @@ static void destroy_context(AVFContext* ctx)
ctx->avf_delegate = NULL;
ctx->avf_audio_delegate = NULL;
+ av_freep(&ctx->url);
av_freep(&ctx->audio_buffer);
pthread_mutex_destroy(&ctx->frame_lock);
@@ -311,14 +313,14 @@ static void destroy_context(AVFContext* ctx)
static void parse_device_name(AVFormatContext *s)
{
AVFContext *ctx = (AVFContext*)s->priv_data;
- char *tmp = av_strdup(s->url);
+ ctx->url = av_strdup(s->url);
char *save;
- if (tmp[0] != ':') {
- ctx->video_filename = av_strtok(tmp, ":", &save);
+ if (ctx->url[0] != ':') {
+ ctx->video_filename = av_strtok(ctx->url, ":", &save);
ctx->audio_filename = av_strtok(NULL, ":", &save);
} else {
- ctx->audio_filename = av_strtok(tmp, ":", &save);
+ ctx->audio_filename = av_strtok(ctx->url, ":", &save);
}
}