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