libcamera: formats: Fix planes bounds check

The plane validation in the stride helper incorrectly accepts the number
of planes as a plane index. Fix the off by one issue.

Fixes: e83727a194 ("libcamera: PixelFormatInfo: Add functions stride and frameSize")
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham 2024-02-26 09:48:56 +00:00
parent 26d9e36d3e
commit 25a8d8b8a9

View file

@ -997,7 +997,7 @@ unsigned int PixelFormatInfo::stride(unsigned int width, unsigned int plane,
return 0; return 0;
} }
if (plane > planes.size() || !planes[plane].bytesPerGroup) { if (plane >= planes.size() || !planes[plane].bytesPerGroup) {
LOG(Formats, Warning) << "Invalid plane index, stride is zero"; LOG(Formats, Warning) << "Invalid plane index, stride is zero";
return 0; return 0;
} }