Check array index before inspecting it

main
Luis Díaz Más 4 years ago
parent 240a72468e
commit 825c0c72bc

@ -22,6 +22,8 @@
#include "config.h" #include "config.h"
#ifdef EXV_HAVE_LIBZ #ifdef EXV_HAVE_LIBZ
#include <zlib.h> // To uncompress or compress text chunk
#include "enforce.hpp" #include "enforce.hpp"
#include "error.hpp" #include "error.hpp"
#include "exif.hpp" #include "exif.hpp"
@ -33,8 +35,6 @@
#include "safe_op.hpp" #include "safe_op.hpp"
#include "tiffimage.hpp" #include "tiffimage.hpp"
#include <zlib.h> // To uncompress or compress text chunk
// standard includes // standard includes
#include <algorithm> #include <algorithm>
#include <cassert> #include <cassert>
@ -108,7 +108,7 @@ namespace Exiv2
// Search for null char until the end of the DataBuf // Search for null char until the end of the DataBuf
const byte* dataPtr = data.c_data(); const byte* dataPtr = data.c_data();
int keysize = offset; int keysize = offset;
while (dataPtr[keysize] != 0 && keysize < data.size()) { while (keysize < data.size() && dataPtr[keysize] != 0) {
keysize++; keysize++;
} }

Loading…
Cancel
Save