From: Yann Collet Date: Mon, 29 Oct 2018 20:57:37 +0000 (-0700) Subject: fixed memcpy() on NULL warning X-Git-Tag: v1.3.8~58^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c5809820081cbee89984052763846e29c67bd0e;p=thirdparty%2Fzstd.git fixed memcpy() on NULL warning memcpy(NULL, src, 0) is undefined behavior. --- diff --git a/lib/decompress/zstd_decompress.c b/lib/decompress/zstd_decompress.c index 2491f4dfb..61826e3af 100644 --- a/lib/decompress/zstd_decompress.c +++ b/lib/decompress/zstd_decompress.c @@ -508,7 +508,10 @@ static size_t ZSTD_copyRawBlock(void* dst, size_t dstCapacity, const void* src, size_t srcSize) { DEBUGLOG(5, "ZSTD_copyRawBlock"); - if (dst == NULL) dstCapacity = 0; /* better safe than sorry */ + if (dst == NULL) { + if (srcSize == 0) return 0; + return ERROR(dstSize_tooSmall); + } if (srcSize > dstCapacity) return ERROR(dstSize_tooSmall); memcpy(dst, src, srcSize); return srcSize;