From 825c0c72bccf2610bcd031b716c0e2905664134d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20D=C3=ADaz=20M=C3=A1s?= Date: Fri, 7 Jan 2022 08:21:05 +0100 Subject: [PATCH] Check array index before inspecting it --- src/pngchunk_int.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 4068da86..b1db4999 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -22,6 +22,8 @@ #include "config.h" #ifdef EXV_HAVE_LIBZ +#include // To uncompress or compress text chunk + #include "enforce.hpp" #include "error.hpp" #include "exif.hpp" @@ -33,8 +35,6 @@ #include "safe_op.hpp" #include "tiffimage.hpp" -#include // To uncompress or compress text chunk - // standard includes #include #include @@ -108,7 +108,7 @@ namespace Exiv2 // Search for null char until the end of the DataBuf const byte* dataPtr = data.c_data(); int keysize = offset; - while (dataPtr[keysize] != 0 && keysize < data.size()) { + while (keysize < data.size() && dataPtr[keysize] != 0) { keysize++; }