summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorW. Felix Handte <w@felixhandte.com>2018-02-02 16:25:29 (GMT)
committerW. Felix Handte <w@felixhandte.com>2018-03-12 18:58:43 (GMT)
commitf34fb3c42dbb824af97800eefdb487dff31e0c13 (patch)
tree5fd7043c57975a2bdca8017c54d965e911d910ac /tests
parent5709891de6513ee8253f27e8d3207ec1fdcff14b (diff)
downloadlz4-f34fb3c42dbb824af97800eefdb487dff31e0c13.zip
lz4-f34fb3c42dbb824af97800eefdb487dff31e0c13.tar.gz
lz4-f34fb3c42dbb824af97800eefdb487dff31e0c13.tar.bz2
Add Bounds Check to locateBuffDiff
Diffstat (limited to 'tests')
-rw-r--r--tests/frametest.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/frametest.c b/tests/frametest.c
index 88d0afd..986a16d 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -730,15 +730,17 @@ _output_error:
static void locateBuffDiff(const void* buff1, const void* buff2, size_t size, unsigned nonContiguous)
{
- int p=0;
+ size_t p=0;
const BYTE* b1=(const BYTE*)buff1;
const BYTE* b2=(const BYTE*)buff2;
if (nonContiguous) {
DISPLAY("Non-contiguous output test (%i bytes)\n", (int)size);
return;
}
- while (b1[p]==b2[p]) p++;
- DISPLAY("Error at pos %i/%i : %02X != %02X \n", p, (int)size, b1[p], b2[p]);
+ while (p < size && b1[p]==b2[p]) p++;
+ if (p != size) {
+ DISPLAY("Error at pos %i/%i : %02X != %02X \n", (int)p, (int)size, b1[p], b2[p]);
+ }
}