ext/zstdruby/libzstd/legacy/zstd_v02.c in zstd-ruby-1.4.4.0 vs ext/zstdruby/libzstd/legacy/zstd_v02.c in zstd-ruby-1.4.5.0
- old
+ new
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
+ * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
* LICENSE file in the root directory of this source tree) and the GPLv2 (found
* in the COPYING file in the root directory of this source tree).
@@ -9,11 +9,11 @@
*/
#include <stddef.h> /* size_t, ptrdiff_t */
#include "zstd_v02.h"
-#include "error_private.h"
+#include "../common/error_private.h"
/******************************************
* Compiler-specific
******************************************/
@@ -187,11 +187,11 @@
MEM_STATIC void MEM_write16(void* memPtr, U16 value)
{
memcpy(memPtr, &value, sizeof(value));
}
-#endif // MEM_FORCE_MEMORY_ACCESS
+#endif /* MEM_FORCE_MEMORY_ACCESS */
MEM_STATIC U16 MEM_readLE16(const void* memPtr)
{
if (MEM_isLittleEndian())
@@ -2834,11 +2834,13 @@
}
static size_t ZSTD_copyUncompressedBlock(void* dst, size_t maxDstSize, const void* src, size_t srcSize)
{
if (srcSize > maxDstSize) return ERROR(dstSize_tooSmall);
- memcpy(dst, src, srcSize);
+ if (srcSize > 0) {
+ memcpy(dst, src, srcSize);
+ }
return srcSize;
}
/** ZSTD_decompressLiterals
@@ -3227,11 +3229,13 @@
/* last literal segment */
{
size_t lastLLSize = litEnd - litPtr;
if (litPtr > litEnd) return ERROR(corruption_detected);
if (op+lastLLSize > oend) return ERROR(dstSize_tooSmall);
- if (op != litPtr) memmove(op, litPtr, lastLLSize);
- op += lastLLSize;
+ if (lastLLSize > 0) {
+ if (op != litPtr) memmove(op, litPtr, lastLLSize);
+ op += lastLLSize;
+ }
}
}
return op-ostart;
}