summaryrefslogtreecommitdiff
path: root/libavformat/hlsenc.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-08 21:40:29 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-10 22:30:43 +0200
commit6db81e93a95d150ec828214ba7eb6183577c748c (patch)
tree61046e84dcb8db13115f979dc6a9ae29854eafc5 /libavformat/hlsenc.c
parent21553d2082a8b5997c25b7b13a9b3426ac43e116 (diff)
downloadffmpeg-6db81e93a95d150ec828214ba7eb6183577c748c.tar.gz
avformat/hlsenc: Simplify setting base_output_dirname
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/hlsenc.c')
-rw-r--r--libavformat/hlsenc.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index d80852739e..be54957e9d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2908,24 +2908,18 @@ static int hls_init(AVFormatContext *s)
return ret;
}
- fmp4_init_filename_len = strlen(vs->m3u8_name) +
- strlen(vs->fmp4_init_filename) + 1;
-
- vs->base_output_dirname = av_malloc(fmp4_init_filename_len);
- if (!vs->base_output_dirname)
- return AVERROR(ENOMEM);
-
- av_strlcpy(vs->base_output_dirname, vs->m3u8_name,
- fmp4_init_filename_len);
- p = strrchr(vs->base_output_dirname, '/');
+ p = strrchr(vs->m3u8_name, '/');
if (p) {
- *(p + 1) = '\0';
- av_strlcat(vs->base_output_dirname, vs->fmp4_init_filename,
- fmp4_init_filename_len);
+ char tmp = *(++p);
+ *p = '\0';
+ vs->base_output_dirname = av_asprintf("%s%s", vs->m3u8_name,
+ vs->fmp4_init_filename);
+ *p = tmp;
} else {
- av_strlcpy(vs->base_output_dirname, vs->fmp4_init_filename,
- fmp4_init_filename_len);
+ vs->base_output_dirname = av_strdup(vs->fmp4_init_filename);
}
+ if (!vs->base_output_dirname)
+ return AVERROR(ENOMEM);
}
}