Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[Coverity] Fix coverity in issue `Overflowed integer argument` in samples (#30059)

Pawel Raasz1a893fa19259
diff --git a/samples/c/common/opencv_c_wrapper/src/bmp_reader.c b/samples/c/common/opencv_c_wrapper/src/bmp_reader.c
index 5e0bdf1e51d..003a2c900b8 100644
--- a/samples/c/common/opencv_c_wrapper/src/bmp_reader.c
+++ b/samples/c/common/opencv_c_wrapper/src/bmp_reader.c
@@ -67,7 +67,7 @@ int readBmpImage(const char* fileName, BitMap* image) {
CLEANUP_AND_RETURN(2);
}
- image->width = image->infoHeader.width;
+ image->width = (image->infoHeader.width > 0) ? image->infoHeader.width : 0;
image->height = abs(image->infoHeader.height);
if (image->infoHeader.bits != 24) {
@@ -80,8 +80,8 @@ int readBmpImage(const char* fileName, BitMap* image) {
CLEANUP_AND_RETURN(4);
}
- int padSize = image->width & 3;
- size_t row_size = (size_t)image->width * 3;
+ size_t padSize = (size_t)image->width & 3U;
+ size_t row_size = (size_t)image->width * 3U;
char pad[3];
size_t size = row_size * (size_t)image->height;