mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-11 09:35:22 +00:00
avformat/hlsenc: fix memleak in hlsenc
fix CID: 1398364 Resource leak refine the code of the new options Reviewed-by: Bodecs Bela <bodecsb@vivanet.hu> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
This commit is contained in:
parent
8c9c43fc43
commit
93593674bc
@ -446,11 +446,18 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double
|
|||||||
if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
|
if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
|
||||||
strlen(hls->current_segment_final_filename_fmt)) {
|
strlen(hls->current_segment_final_filename_fmt)) {
|
||||||
char * old_filename = av_strdup(hls->avf->filename); // %%s will be %s after strftime
|
char * old_filename = av_strdup(hls->avf->filename); // %%s will be %s after strftime
|
||||||
|
if (!old_filename) {
|
||||||
|
av_free(en);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
av_strlcpy(hls->avf->filename, hls->current_segment_final_filename_fmt, sizeof(hls->avf->filename));
|
av_strlcpy(hls->avf->filename, hls->current_segment_final_filename_fmt, sizeof(hls->avf->filename));
|
||||||
if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {
|
if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {
|
||||||
char * filename = av_strdup(hls->avf->filename); // %%s will be %s after strftime
|
char * filename = av_strdup(hls->avf->filename); // %%s will be %s after strftime
|
||||||
if (!filename)
|
if (!filename) {
|
||||||
|
av_free(old_filename);
|
||||||
|
av_free(en);
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
if (replace_int_data_in_filename(hls->avf->filename, sizeof(hls->avf->filename),
|
if (replace_int_data_in_filename(hls->avf->filename, sizeof(hls->avf->filename),
|
||||||
filename, 's', pos + size) < 1) {
|
filename, 's', pos + size) < 1) {
|
||||||
av_log(hls, AV_LOG_ERROR,
|
av_log(hls, AV_LOG_ERROR,
|
||||||
@ -459,14 +466,18 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double
|
|||||||
filename);
|
filename);
|
||||||
av_free(filename);
|
av_free(filename);
|
||||||
av_free(old_filename);
|
av_free(old_filename);
|
||||||
|
av_free(en);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
av_free(filename);
|
av_free(filename);
|
||||||
}
|
}
|
||||||
if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {
|
if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {
|
||||||
char * filename = av_strdup(hls->avf->filename); // %%t will be %t after strftime
|
char * filename = av_strdup(hls->avf->filename); // %%t will be %t after strftime
|
||||||
if (!filename)
|
if (!filename) {
|
||||||
|
av_free(old_filename);
|
||||||
|
av_free(en);
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
}
|
||||||
if (replace_int_data_in_filename(hls->avf->filename, sizeof(hls->avf->filename),
|
if (replace_int_data_in_filename(hls->avf->filename, sizeof(hls->avf->filename),
|
||||||
filename, 't', (int64_t)round(1000000 * duration)) < 1) {
|
filename, 't', (int64_t)round(1000000 * duration)) < 1) {
|
||||||
av_log(hls, AV_LOG_ERROR,
|
av_log(hls, AV_LOG_ERROR,
|
||||||
@ -475,6 +486,7 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double
|
|||||||
filename);
|
filename);
|
||||||
av_free(filename);
|
av_free(filename);
|
||||||
av_free(old_filename);
|
av_free(old_filename);
|
||||||
|
av_free(en);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
av_free(filename);
|
av_free(filename);
|
||||||
|
Loading…
Reference in New Issue
Block a user