[FFmpeg-devel] [PATCH 1/2] webdashenc: Add failure check for av_malloc.
Vignesh Venkatasubramanian
vigneshv at google.com
Mon Apr 13 21:16:31 CEST 2015
Add a missing failure check for av_malloc call.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
---
libavformat/webmdashenc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c
index c5347a9..80266f7 100644
--- a/libavformat/webmdashenc.c
+++ b/libavformat/webmdashenc.c
@@ -87,7 +87,7 @@ static double get_duration(AVFormatContext *s)
return max / 1000;
}
-static void write_header(AVFormatContext *s)
+static int write_header(AVFormatContext *s)
{
WebMDashMuxContext *w = s->priv_data;
double min_buffer_time = 1.0;
@@ -110,6 +110,7 @@ static void write_header(AVFormatContext *s)
struct tm gmt_buffer;
struct tm *gmt = gmtime_r(&local_time, &gmt_buffer);
char *gmt_iso = av_malloc(21);
+ if (!gmt_iso) return AVERROR(ENOMEM);
strftime(gmt_iso, 21, "%Y-%m-%dT%H:%M:%SZ", gmt);
if (w->debug_mode) {
av_strlcpy(gmt_iso, "", 1);
@@ -124,6 +125,7 @@ static void write_header(AVFormatContext *s)
w->utc_timing_url ? w->utc_timing_url : gmt_iso);
av_free(gmt_iso);
}
+ return 0;
}
static void write_footer(AVFormatContext *s)
@@ -456,7 +458,7 @@ static int webm_dash_manifest_write_header(AVFormatContext *s)
double start = 0.0;
WebMDashMuxContext *w = s->priv_data;
parse_adaptation_sets(s);
- write_header(s);
+ if (write_header(s) < 0) return -1;
avio_printf(s->pb, "<Period id=\"0\"");
avio_printf(s->pb, " start=\"PT%gS\"", start);
if (!w->is_live) {
--
2.2.0.rc0.207.ga3a616c
More information about the ffmpeg-devel
mailing list