That said, instead of aborting the operation, perhaps it'd make more sense
for library functions to be av_saturated_add(), av_saturated_sub() which
saturate to INT64_MIN/MAX.

- dale

On Thu, Apr 30, 2020 at 1:26 PM Dale Curtis <dalecur...@chromium.org> wrote:

> Aside: This overflow check is used in quite a few places now. I wonder if
> it's worth having a function like the following:
>
> int64_t av_no_overflow_add(int64_t a, int64_t b) {
>   return (a > 0 ? b <= INT64_MAX - a : b >= INT64_MIN - a) ? a + b : a;
> }
>
> Better name suggestions welcome... av_maybe_add_ts?
>
> On Thu, Apr 30, 2020 at 1:17 PM Dale Curtis <dalecur...@chromium.org>
> wrote:
>
>> This applies the same workaround used elsewhere in the file for handling
>> overflow of addition.
>>
>> Signed-off-by: Dale Curtis <dalecur...@chromium.org>
>> ---
>>  libavformat/utils.c | 15 +++++++++++----
>>  1 file changed, 11 insertions(+), 4 deletions(-)
>>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to