From: Yann Collet Date: Sun, 14 Jan 2018 06:47:46 +0000 (-0800) Subject: ensure a ptr is non-null X-Git-Tag: upstream/1.9.3~11^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=18b4c66d257a583b09e85243d21a23638b618411;p=platform%2Fupstream%2Flz4.git ensure a ptr is non-null with an assert() to help static analyzer understanding this condition. --- 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 +#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)