Commit b5508f74 authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian Committed by Michael Niedermayer

lavf/webmdashenc: fix unchecked strftime

Fix unchecked strftime return value. This patch fixes Coverity
CID 1295086.
Signed-off-by: 's avatarVignesh Venkatasubramanian <vigneshv@google.com>
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 47cbcf20
...@@ -88,7 +88,7 @@ static double get_duration(AVFormatContext *s) ...@@ -88,7 +88,7 @@ static double get_duration(AVFormatContext *s)
return max / 1000; return max / 1000;
} }
static void write_header(AVFormatContext *s) static int write_header(AVFormatContext *s)
{ {
WebMDashMuxContext *w = s->priv_data; WebMDashMuxContext *w = s->priv_data;
double min_buffer_time = 1.0; double min_buffer_time = 1.0;
...@@ -111,7 +111,9 @@ static void write_header(AVFormatContext *s) ...@@ -111,7 +111,9 @@ static void write_header(AVFormatContext *s)
struct tm gmt_buffer; struct tm gmt_buffer;
struct tm *gmt = gmtime_r(&local_time, &gmt_buffer); struct tm *gmt = gmtime_r(&local_time, &gmt_buffer);
char gmt_iso[21]; char gmt_iso[21];
strftime(gmt_iso, 21, "%Y-%m-%dT%H:%M:%SZ", gmt); if (!strftime(gmt_iso, 21, "%Y-%m-%dT%H:%M:%SZ", gmt)) {
return AVERROR_UNKNOWN;
}
if (w->debug_mode) { if (w->debug_mode) {
av_strlcpy(gmt_iso, "", 1); av_strlcpy(gmt_iso, "", 1);
} }
...@@ -125,6 +127,7 @@ static void write_header(AVFormatContext *s) ...@@ -125,6 +127,7 @@ static void write_header(AVFormatContext *s)
avio_printf(s->pb, " value=\"%s\"/>\n", w->utc_timing_url); avio_printf(s->pb, " value=\"%s\"/>\n", w->utc_timing_url);
} }
} }
return 0;
} }
static void write_footer(AVFormatContext *s) static void write_footer(AVFormatContext *s)
...@@ -474,10 +477,12 @@ static int webm_dash_manifest_write_header(AVFormatContext *s) ...@@ -474,10 +477,12 @@ static int webm_dash_manifest_write_header(AVFormatContext *s)
WebMDashMuxContext *w = s->priv_data; WebMDashMuxContext *w = s->priv_data;
ret = parse_adaptation_sets(s); ret = parse_adaptation_sets(s);
if (ret < 0) { if (ret < 0) {
free_adaptation_sets(s); goto fail;
return ret; }
ret = write_header(s);
if (ret < 0) {
goto fail;
} }
write_header(s);
avio_printf(s->pb, "<Period id=\"0\""); avio_printf(s->pb, "<Period id=\"0\"");
avio_printf(s->pb, " start=\"PT%gS\"", start); avio_printf(s->pb, " start=\"PT%gS\"", start);
if (!w->is_live) { if (!w->is_live) {
...@@ -488,14 +493,15 @@ static int webm_dash_manifest_write_header(AVFormatContext *s) ...@@ -488,14 +493,15 @@ static int webm_dash_manifest_write_header(AVFormatContext *s)
for (i = 0; i < w->nb_as; i++) { for (i = 0; i < w->nb_as; i++) {
ret = write_adaptation_set(s, i); ret = write_adaptation_set(s, i);
if (ret < 0) { if (ret < 0) {
free_adaptation_sets(s); goto fail;
return ret;
} }
} }
avio_printf(s->pb, "</Period>\n"); avio_printf(s->pb, "</Period>\n");
write_footer(s); write_footer(s);
return 0; fail:
free_adaptation_sets(s);
return ret < 0 ? ret : 0;
} }
static int webm_dash_manifest_write_packet(AVFormatContext *s, AVPacket *pkt) static int webm_dash_manifest_write_packet(AVFormatContext *s, AVPacket *pkt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment