Signed integer overflow is undefined behavior. Detected with clang and -fsanitize=signed-integer-overflow
Showing the changes to libavformat (1 of 1 file). Show all
Unified · Split
| @@ -259,6 +259,8 @@ int64_t avio_seek(AVIOContext *s, int64_t offset, int whence) · 258 unmodified lines | ||
| 259 | 259 | offset1 = pos + (s->buf_ptr - s->buffer); |
| 260 | 260 | if (offset == 0) |
| 261 | 261 | return offset1; |
| 262 | + if (offset > INT64_MAX - offset1) | |
| 263 | + return AVERROR(EINVAL); | |
| 262 | 264 | offset += offset1; |
| 263 | 265 | } |
| 264 | 266 | if (offset < 0) |