Corrected : linking stage of Visual 2005 in Debug mode (issue 16)

Minor changes in comments

git-svn-id: https://lz4.googlecode.com/svn/trunk@63 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2012-05-07 23:10:02 +00:00
parent 6cedd1f252
commit ae9eead4ae
2 changed files with 62 additions and 53 deletions

24
lz4.c
View File

@ -71,6 +71,7 @@
#endif
// Little Endian or Big Endian ?
// Note : overwrite the below #define if you know your architecture endianess
#if (defined(__BIG_ENDIAN__) || defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN) || defined(_ARCH_PPC) || defined(__PPC__) || defined(__PPC) || defined(PPC) || defined(__powerpc__) || defined(__powerpc) || defined(powerpc) || ((defined(__BYTE_ORDER__)&&(__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))) )
# define LZ4_BIG_ENDIAN 1
#else
@ -103,6 +104,13 @@
#ifdef _MSC_VER // Visual Studio
# define inline __forceinline // Visual is not C99, but supports some kind of inline
# include <intrin.h> // _BitScanForward
# if LZ4_ARCH64 // 64-bit
# pragma intrinsic(_BitScanForward64) // For Visual 2005
# pragma intrinsic(_BitScanReverse64) // For Visual 2005
# else
# pragma intrinsic(_BitScanForward) // For Visual 2005
# pragma intrinsic(_BitScanReverse) // For Visual 2005
# endif
#endif
#ifdef _MSC_VER
@ -663,7 +671,7 @@ int LZ4_uncompress(const char* source,
cpy = op+length;
if unlikely(cpy>oend-COPYLENGTH)
{
if (cpy > oend) goto _output_error;
if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer
memcpy(op, ip, length);
ip += length;
break; // Necessarily EOF
@ -672,7 +680,7 @@ int LZ4_uncompress(const char* source,
// get offset
LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2;
if (ref < (BYTE* const)dest) goto _output_error;
if (ref < (BYTE* const)dest) goto _output_error; // Error : offset create reference outside destination buffer
// get matchlength
if ((length=(token&ML_MASK)) == ML_MASK) { for (;*ip==255;length+=255) {ip++;} length += *ip++; }
@ -697,7 +705,7 @@ int LZ4_uncompress(const char* source,
cpy = op + length - (STEPSIZE-4);
if (cpy>oend-COPYLENGTH)
{
if (cpy > oend) goto _output_error;
if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer
LZ4_SECURECOPY(ref, op, (oend-COPYLENGTH));
while(op<cpy) *op++=*ref++;
op=cpy;
@ -749,19 +757,19 @@ int LZ4_uncompress_unknownOutputSize(
cpy = op+length;
if ((cpy>oend-COPYLENGTH) || (ip+length>iend-COPYLENGTH))
{
if (cpy > oend) goto _output_error;
if (ip+length > iend) goto _output_error;
if (cpy > oend) goto _output_error; // Error : request to write beyond destination buffer
if (ip+length > iend) goto _output_error; // Error : request to read beyond source buffer
memcpy(op, ip, length);
op += length;
ip += length;
if (ip<iend) goto _output_error;
if (ip<iend) goto _output_error; // Error : LZ4 format violation
break; // Necessarily EOF, due to parsing restrictions
}
LZ4_WILDCOPY(ip, op, cpy); ip -= (op-cpy); op = cpy;
// get offset
LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2;
if (ref < (BYTE* const)dest) goto _output_error;
if (ref < (BYTE* const)dest) goto _output_error; // Error : offset creates reference outside of destination buffer
// get matchlength
if ((length=(token&ML_MASK)) == ML_MASK) { while (ip<iend) { int s = *ip++; length +=s; if (s==255) continue; break; } }
@ -786,7 +794,7 @@ int LZ4_uncompress_unknownOutputSize(
cpy = op + length - (STEPSIZE-4);
if (cpy>oend-COPYLENGTH)
{
if (cpy > oend) goto _output_error;
if (cpy > oend) goto _output_error; // Error : request to write outside of destination buffer
LZ4_SECURECOPY(ref, op, (oend-COPYLENGTH));
while(op<cpy) *op++=*ref++;
op=cpy;

3
lz4.h
View File

@ -85,7 +85,8 @@ LZ4_uncompress_unknownOutputSize() :
return : the number of bytes decoded in the destination buffer (necessarily <= maxOutputSize)
If the source stream is malformed, the function will stop decoding and return a negative result, indicating the byte position of the faulty instruction
This function never writes beyond dest + maxOutputSize, and is therefore protected against malicious data packets
note : This version is slightly slower than LZ4_uncompress()
note : Destination buffer must be already allocated.
This version is slightly slower than LZ4_uncompress()
*/