summaryrefslogtreecommitdiffstats
path: root/tests/frametest.c
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2020-10-02 06:42:42 (GMT)
committerYann Collet <cyan@fb.com>2020-10-02 06:42:42 (GMT)
commit056cdd6cc67fbce0f83c59e30dd6a1196d59727f (patch)
tree42cf5090fffe73fd84e3ef22303ee9da860dc879 /tests/frametest.c
parenta88c8fb43875361e2dd6a0c9f84099c24dc89671 (diff)
downloadlz4-056cdd6cc67fbce0f83c59e30dd6a1196d59727f.zip
lz4-056cdd6cc67fbce0f83c59e30dd6a1196d59727f.tar.gz
lz4-056cdd6cc67fbce0f83c59e30dd6a1196d59727f.tar.bz2
define sentinelTest
to help scan-build detect the condition
Diffstat (limited to 'tests/frametest.c')
-rw-r--r--tests/frametest.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/frametest.c b/tests/frametest.c
index 70f949d..2633c90 100644
--- a/tests/frametest.c
+++ b/tests/frametest.c
@@ -839,13 +839,14 @@ size_t test_lz4f_decompression_wBuffers(
size_t iSize = iSizeMax;
size_t const oSizeCand = (FUZ_rand(randState) & ((1<<nbBitsO)-1)) + 2;
size_t const oSizeMax = MIN(oSizeCand, (size_t)(oend-op));
+ int const sentinelTest = (op + oSizeMax < oend);
size_t oSize = oSizeMax;
BYTE const mark = (BYTE)(FUZ_rand(randState) & 255);
LZ4F_decompressOptions_t dOptions;
memset(&dOptions, 0, sizeof(dOptions));
dOptions.stableDst = FUZ_rand(randState) & 1;
if (o_scenario == o_overwrite) dOptions.stableDst = 0; /* overwrite mode */
- if (op + oSizeMax < oend) op[oSizeMax] = mark;
+ if (sentinelTest) op[oSizeMax] = mark;
DISPLAYLEVEL(7, "dstCapacity=%u, presentedInput=%u \n", (unsigned)oSize, (unsigned)iSize);
@@ -860,7 +861,7 @@ size_t test_lz4f_decompression_wBuffers(
}
DISPLAYLEVEL(7, "oSize=%u, readSize=%u \n", (unsigned)oSize, (unsigned)iSize);
- if (op + oSizeMax < oend) {
+ if (sentinelTest) {
CHECK(op[oSizeMax] != mark, "op[oSizeMax] = %02X != %02X : "
"Decompression overwrites beyond assigned dst size",
op[oSizeMax], mark);