Merge pull request #1547 from shakeelrao/fix-error
Fix incorrect error code in ZSTD_errorFrameSizeInfo
This commit is contained in:
commit
f52a7d8faa
@ -437,7 +437,7 @@ static size_t ZSTD_decodeFrameHeader(ZSTD_DCtx* dctx, const void* src, size_t he
|
|||||||
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
|
* Contains the compressed frame size and an upper-bound for the decompressed frame size.
|
||||||
* Note: before using `compressedSize` you must check for errors using ZSTD_isError().
|
* Note: before using `compressedSize` you must check for errors using ZSTD_isError().
|
||||||
* similarly, before using `decompressedBound`, you must check for errors using:
|
* similarly, before using `decompressedBound`, you must check for errors using:
|
||||||
* `decompressedBound` != ZSTD_CONTENTSIZE_UNKNOWN
|
* `decompressedBound` != ZSTD_CONTENTSIZE_ERROR
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
size_t compressedSize;
|
size_t compressedSize;
|
||||||
@ -448,7 +448,7 @@ static ZSTD_frameSizeInfo ZSTD_errorFrameSizeInfo(size_t ret)
|
|||||||
{
|
{
|
||||||
ZSTD_frameSizeInfo frameSizeInfo;
|
ZSTD_frameSizeInfo frameSizeInfo;
|
||||||
frameSizeInfo.compressedSize = ret;
|
frameSizeInfo.compressedSize = ret;
|
||||||
frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_UNKNOWN;
|
frameSizeInfo.decompressedBound = ZSTD_CONTENTSIZE_ERROR;
|
||||||
return frameSizeInfo;
|
return frameSizeInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,6 +383,13 @@ static int basicUnitTests(U32 seed, double compressibility)
|
|||||||
}
|
}
|
||||||
DISPLAYLEVEL(3, "OK \n");
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
|
|
||||||
|
DISPLAYLEVEL(3, "test%3i : ZSTD_decompressBound test with invalid srcSize : ", testNb++);
|
||||||
|
{
|
||||||
|
unsigned long long bound = ZSTD_decompressBound(compressedBuffer, cSize - 1);
|
||||||
|
if (bound != ZSTD_CONTENTSIZE_ERROR) goto _output_error;
|
||||||
|
}
|
||||||
|
DISPLAYLEVEL(3, "OK \n");
|
||||||
|
|
||||||
DISPLAYLEVEL(3, "test%3i : decompress %u bytes : ", testNb++, (unsigned)CNBuffSize);
|
DISPLAYLEVEL(3, "test%3i : decompress %u bytes : ", testNb++, (unsigned)CNBuffSize);
|
||||||
{ size_t const r = ZSTD_decompress(decodedBuffer, CNBuffSize, compressedBuffer, cSize);
|
{ size_t const r = ZSTD_decompress(decodedBuffer, CNBuffSize, compressedBuffer, cSize);
|
||||||
if (r != CNBuffSize) goto _output_error; }
|
if (r != CNBuffSize) goto _output_error; }
|
||||||
|
@ -16,10 +16,11 @@
|
|||||||
/*===========================================
|
/*===========================================
|
||||||
* Dependencies
|
* Dependencies
|
||||||
*==========================================*/
|
*==========================================*/
|
||||||
#include <stddef.h> /* size_t */
|
#include <stddef.h> /* size_t */
|
||||||
#include <stdlib.h> /* malloc, free */
|
#include <stdlib.h> /* malloc, free */
|
||||||
#include <stdio.h> /* fprintf */
|
#include <stdio.h> /* fprintf */
|
||||||
#include <string.h> /* strlen */
|
#include <string.h> /* strlen */
|
||||||
|
#define ZSTD_STATIC_LINKING_ONLY /* ZSTD_decompressBound */
|
||||||
#include "zstd.h"
|
#include "zstd.h"
|
||||||
#include "zstd_errors.h"
|
#include "zstd_errors.h"
|
||||||
|
|
||||||
@ -130,12 +131,24 @@ static int testStreamingAPI(void)
|
|||||||
return error_code;
|
return error_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int testFrameDecoding(void)
|
||||||
|
{
|
||||||
|
if (ZSTD_decompressBound(COMPRESSED, COMPRESSED_SIZE) != ZSTD_CONTENTSIZE_ERROR) {
|
||||||
|
DISPLAY("ERROR: ZSTD_decompressBound: Expected to receive ZSTD_CONTENTSIZE_ERROR\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
DISPLAY("Frame Decoding OK\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
{ int const ret = testSimpleAPI();
|
{ int const ret = testSimpleAPI();
|
||||||
if (ret) return ret; }
|
if (ret) return ret; }
|
||||||
{ int const ret = testStreamingAPI();
|
{ int const ret = testStreamingAPI();
|
||||||
if (ret) return ret; }
|
if (ret) return ret; }
|
||||||
|
{ int const ret = testFrameDecoding();
|
||||||
|
if (ret) return ret; }
|
||||||
|
|
||||||
DISPLAY("OK\n");
|
DISPLAY("OK\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user