[v1] apps: common: image: Fix assertion
diff mbox series

Message ID 20250613143719.1131707-1-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v1] apps: common: image: Fix assertion
Related show

Commit Message

Barnabás Pőcze June 13, 2025, 2:37 p.m. UTC
`plane` must be strictly less than the vector's size,
it cannot be equal to it.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/apps/common/image.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kieran Bingham June 13, 2025, 3:16 p.m. UTC | #1
Quoting Barnabás Pőcze (2025-06-13 15:37:19)
> `plane` must be strictly less than the vector's size,
> it cannot be equal to it.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/apps/common/image.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/apps/common/image.cpp b/src/apps/common/image.cpp
> index a2a0f58f3..9a67238aa 100644
> --- a/src/apps/common/image.cpp
> +++ b/src/apps/common/image.cpp
> @@ -98,12 +98,12 @@ unsigned int Image::numPlanes() const
>  
>  Span<uint8_t> Image::data(unsigned int plane)
>  {
> -       assert(plane <= planes_.size());
> +       assert(plane < planes_.size());
>         return planes_[plane];
>  }
>  
>  Span<const uint8_t> Image::data(unsigned int plane) const
>  {
> -       assert(plane <= planes_.size());
> +       assert(plane < planes_.size());
>         return planes_[plane];
>  }
> -- 
> 2.49.0
>
Laurent Pinchart June 15, 2025, 12:18 a.m. UTC | #2
On Fri, Jun 13, 2025 at 04:37:19PM +0200, Barnabás Pőcze wrote:
> `plane` must be strictly less than the vector's size,
> it cannot be equal to it.
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  src/apps/common/image.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/apps/common/image.cpp b/src/apps/common/image.cpp
> index a2a0f58f3..9a67238aa 100644
> --- a/src/apps/common/image.cpp
> +++ b/src/apps/common/image.cpp
> @@ -98,12 +98,12 @@ unsigned int Image::numPlanes() const
>  
>  Span<uint8_t> Image::data(unsigned int plane)
>  {
> -	assert(plane <= planes_.size());
> +	assert(plane < planes_.size());
>  	return planes_[plane];
>  }
>  
>  Span<const uint8_t> Image::data(unsigned int plane) const
>  {
> -	assert(plane <= planes_.size());
> +	assert(plane < planes_.size());
>  	return planes_[plane];
>  }

Patch
diff mbox series

diff --git a/src/apps/common/image.cpp b/src/apps/common/image.cpp
index a2a0f58f3..9a67238aa 100644
--- a/src/apps/common/image.cpp
+++ b/src/apps/common/image.cpp
@@ -98,12 +98,12 @@  unsigned int Image::numPlanes() const
 
 Span<uint8_t> Image::data(unsigned int plane)
 {
-	assert(plane <= planes_.size());
+	assert(plane < planes_.size());
 	return planes_[plane];
 }
 
 Span<const uint8_t> Image::data(unsigned int plane) const
 {
-	assert(plane <= planes_.size());
+	assert(plane < planes_.size());
 	return planes_[plane];
 }