Skip to content

Commit 825c0c7

Browse files
committed
Check array index before inspecting it
1 parent 240a724 commit 825c0c7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/pngchunk_int.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "config.h"
2323

2424
#ifdef EXV_HAVE_LIBZ
25+
#include <zlib.h> // To uncompress or compress text chunk
26+
2527
#include "enforce.hpp"
2628
#include "error.hpp"
2729
#include "exif.hpp"
@@ -33,8 +35,6 @@
3335
#include "safe_op.hpp"
3436
#include "tiffimage.hpp"
3537

36-
#include <zlib.h> // To uncompress or compress text chunk
37-
3838
// standard includes
3939
#include <algorithm>
4040
#include <cassert>
@@ -108,7 +108,7 @@ namespace Exiv2
108108
// Search for null char until the end of the DataBuf
109109
const byte* dataPtr = data.c_data();
110110
int keysize = offset;
111-
while (dataPtr[keysize] != 0 && keysize < data.size()) {
111+
while (keysize < data.size() && dataPtr[keysize] != 0) {
112112
keysize++;
113113
}
114114

0 commit comments

Comments
 (0)