avformat/wavenc: check return value of strftime()
Fixes CID1257006 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
92d47e2aa3
commit
308429e124
@ -252,7 +252,7 @@ static void peak_write_frame(AVFormatContext *s)
|
|||||||
wav->peak_num_frames++;
|
wav->peak_num_frames++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void peak_write_chunk(AVFormatContext *s)
|
static int peak_write_chunk(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
WAVMuxContext *wav = s->priv_data;
|
WAVMuxContext *wav = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
@ -272,8 +272,12 @@ static void peak_write_chunk(AVFormatContext *s)
|
|||||||
av_log(s, AV_LOG_INFO, "Writing local time and date to Peak Envelope Chunk\n");
|
av_log(s, AV_LOG_INFO, "Writing local time and date to Peak Envelope Chunk\n");
|
||||||
now0 = av_gettime();
|
now0 = av_gettime();
|
||||||
now_secs = now0 / 1000000;
|
now_secs = now0 / 1000000;
|
||||||
strftime(timestamp, sizeof(timestamp), "%Y:%m:%d:%H:%M:%S:", localtime_r(&now_secs, &tmpbuf));
|
if (strftime(timestamp, sizeof(timestamp), "%Y:%m:%d:%H:%M:%S:", localtime_r(&now_secs, &tmpbuf))) {
|
||||||
av_strlcatf(timestamp, sizeof(timestamp), "%03d", (int)((now0 / 1000) % 1000));
|
av_strlcatf(timestamp, sizeof(timestamp), "%03d", (int)((now0 / 1000) % 1000));
|
||||||
|
} else {
|
||||||
|
av_log(s, AV_LOG_ERROR, "Failed to write timestamp\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
avio_wl32(pb, 1); /* version */
|
avio_wl32(pb, 1); /* version */
|
||||||
@ -293,6 +297,8 @@ static void peak_write_chunk(AVFormatContext *s)
|
|||||||
|
|
||||||
if (!wav->data)
|
if (!wav->data)
|
||||||
wav->data = peak;
|
wav->data = peak;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int wav_write_header(AVFormatContext *s)
|
static int wav_write_header(AVFormatContext *s)
|
||||||
@ -414,6 +420,7 @@ static int wav_write_trailer(AVFormatContext *s)
|
|||||||
int64_t file_size, data_size;
|
int64_t file_size, data_size;
|
||||||
int64_t number_of_samples = 0;
|
int64_t number_of_samples = 0;
|
||||||
int rf64 = 0;
|
int rf64 = 0;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
avio_flush(pb);
|
avio_flush(pb);
|
||||||
|
|
||||||
@ -424,7 +431,7 @@ static int wav_write_trailer(AVFormatContext *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wav->write_peak && wav->peak_output) {
|
if (wav->write_peak && wav->peak_output) {
|
||||||
peak_write_chunk(s);
|
ret = peak_write_chunk(s);
|
||||||
avio_flush(pb);
|
avio_flush(pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,7 +492,7 @@ static int wav_write_trailer(AVFormatContext *s)
|
|||||||
if (wav->write_peak)
|
if (wav->write_peak)
|
||||||
peak_free_buffers(s);
|
peak_free_buffers(s);
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OFFSET(x) offsetof(WAVMuxContext, x)
|
#define OFFSET(x) offsetof(WAVMuxContext, x)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user