Commit c9bb7fb642 for ffmpeg
commit c9bb7fb6428757dfbe270e92cc91f75723de8f74
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sat Nov 7 22:08:08 2026 +0100
avutil/frame: count the trailing zeros of the whole cropping offset
Fixes: passing zero to __builtin_ctz()
Fixes: bHs7sJdzdvhW
Found during the review of https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25020
Passing zero to __builtin_ctz() Replicated through API with UBSAN
diff --git a/libavutil/frame.c b/libavutil/frame.c
index 81b77ba569..c79c1b76d5 100644
--- a/libavutil/frame.c
+++ b/libavutil/frame.c
@@ -802,7 +802,7 @@ int av_frame_apply_cropping(AVFrame *frame, int flags)
int min_log2_align = INT_MAX;
for (int i = 0; frame->data[i]; i++) {
- int log2_align = offsets[i] ? ff_ctz(offsets[i]) : INT_MAX;
+ int log2_align = offsets[i] ? ff_ctzll(offsets[i]) : INT_MAX;
min_log2_align = FFMIN(log2_align, min_log2_align);
}