From a3ca94f833c16a623a494f3d197955e4c06a490a Mon Sep 17 00:00:00 2001 From: Zach DeVito Date: Thu, 29 Nov 2018 16:56:13 -0800 Subject: [PATCH] guard memcpy when n == 0 because buffer may be NULL --- miniz_zip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/miniz_zip.c b/miniz_zip.c index f42a9ea..7e6bd8f 100644 --- a/miniz_zip.c +++ b/miniz_zip.c @@ -351,7 +351,8 @@ static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zi size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE; - memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); + if (n > 0) + memcpy((mz_uint8 *)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size); return MZ_TRUE; }