From 25a8d8b8a914302f1de02af4b0f5ae70568f00ea Mon Sep 17 00:00:00 2001 From: Kieran Bingham Date: Mon, 26 Feb 2024 09:48:56 +0000 Subject: 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: e83727a194b5 ("libcamera: PixelFormatInfo: Add functions stride and frameSize") Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain Signed-off-by: Kieran Bingham --- src/libcamera/formats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/formats.cpp b/src/libcamera/formats.cpp index 6a3b89a3..955c3fba 100644 --- a/src/libcamera/formats.cpp +++ b/src/libcamera/formats.cpp @@ -997,7 +997,7 @@ unsigned int PixelFormatInfo::stride(unsigned int width, unsigned int plane, 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"; return 0; } -- cgit v1.2.1