summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2018-01-14 06:47:46 (GMT)
committerYann Collet <cyan@fb.com>2018-01-14 06:47:46 (GMT)
commit18b4c66d257a583b09e85243d21a23638b618411 (patch)
tree505a04068f2fca9774d32a73ba1caf0a055f7be1
parent4d61ebc9c8738fc79301d8ef7e27920d4b300913 (diff)
downloadlz4-18b4c66d257a583b09e85243d21a23638b618411.zip
lz4-18b4c66d257a583b09e85243d21a23638b618411.tar.gz
lz4-18b4c66d257a583b09e85243d21a23638b618411.tar.bz2
ensure a ptr is non-null
with an assert() to help static analyzer understanding this condition.
-rw-r--r--lib/lz4frame.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/lz4frame.c b/lib/lz4frame.c
index 62e7010..b5c868f 100644
--- a/lib/lz4frame.c
+++ b/lib/lz4frame.c
@@ -70,6 +70,14 @@ You can contact the author at :
/*-************************************
* Debug
**************************************/
+#if defined(LZ4_DEBUG) && (LZ4_DEBUG>=1)
+# include <assert.h>
+#else
+# ifndef assert
+# define assert(condition) ((void)0)
+# endif
+#endif
+
#define LZ4F_STATIC_ASSERT(c) { enum { LZ4F_static_assert = 1/(int)(!!(c)) }; } /* use only *after* variable declarations */
@@ -1439,6 +1447,7 @@ size_t LZ4F_decompress(LZ4F_dctx* dctx,
case dstage_decodeCBlock:
if (dctx->frameInfo.blockChecksumFlag) {
dctx->tmpInTarget -= 4;
+ assert(selectedIn != NULL); /* selectedIn is defined at this stage (either srcPtr, or dctx->tmpIn) */
{ U32 const readBlockCrc = LZ4F_readLE32(selectedIn + dctx->tmpInTarget);
U32 const calcBlockCrc = XXH32(selectedIn, dctx->tmpInTarget, 0);
if (readBlockCrc != calcBlockCrc)