mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 15:32:53 +01:00
anim_encode: fix integer overflow
calculate the file duration using unsigned math. this could still result in an incorrect average duration calculation if there were multiple rollovers. caching the duration is an option if it was desirable to support such an extreme case. Change-Id: I3875d94d081fec947c03a857055df6e27ff5351d
This commit is contained in:
parent
42c79aa66b
commit
34130afe8b
@ -1536,7 +1536,8 @@ int WebPAnimEncoderAssemble(WebPAnimEncoder* enc, WebPData* webp_data) {
|
||||
|
||||
if (!enc->got_null_frame_ && enc->in_frame_count_ > 1 && enc->count_ > 0) {
|
||||
// set duration of the last frame to be avg of durations of previous frames.
|
||||
const double delta_time = enc->prev_timestamp_ - enc->first_timestamp_;
|
||||
const double delta_time =
|
||||
(uint32_t)enc->prev_timestamp_ - enc->first_timestamp_;
|
||||
const int average_duration = (int)(delta_time / (enc->in_frame_count_ - 1));
|
||||
if (!IncreasePreviousDuration(enc, average_duration)) {
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user