fixed constant comparison on 32-bits systems
This commit is contained in:
+12
-8
@@ -1183,38 +1183,42 @@ static int createContexts(contexts_t* ctx, const char* dictFileName) {
|
|||||||
size_t readSize;
|
size_t readSize;
|
||||||
ctx->cctx = ZSTD_createCCtx();
|
ctx->cctx = ZSTD_createCCtx();
|
||||||
ctx->dctx = ZSTD_createDCtx();
|
ctx->dctx = ZSTD_createDCtx();
|
||||||
|
assert(ctx->cctx != NULL);
|
||||||
|
assert(ctx->dctx != NULL);
|
||||||
|
|
||||||
if(dictFileName == NULL) {
|
if(dictFileName == NULL) {
|
||||||
ctx->dictSize = 0;
|
ctx->dictSize = 0;
|
||||||
ctx->dictBuffer = NULL;
|
ctx->dictBuffer = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ctx->dictSize = UTIL_getFileSize(dictFileName);
|
{ U64 const dictFileSize = UTIL_getFileSize(dictFileName);
|
||||||
assert(ctx->dictSize != UTIL_FILESIZE_UNKNOWN);
|
assert(dictFileSize != UTIL_FILESIZE_UNKNOWN);
|
||||||
|
ctx->dictSize = dictFileSize;
|
||||||
|
assert((U64)ctx->dictSize == dictFileSize); /* check overflow */
|
||||||
|
}
|
||||||
ctx->dictBuffer = malloc(ctx->dictSize);
|
ctx->dictBuffer = malloc(ctx->dictSize);
|
||||||
|
|
||||||
f = fopen(dictFileName, "rb");
|
f = fopen(dictFileName, "rb");
|
||||||
|
|
||||||
if(!f) {
|
if (f==NULL) {
|
||||||
DISPLAY("unable to open file\n");
|
DISPLAY("unable to open file\n");
|
||||||
fclose(f);
|
|
||||||
freeContexts(*ctx);
|
freeContexts(*ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx->dictSize > 64 MB || !(ctx->dictBuffer)) {
|
if (ctx->dictSize > 64 MB || !(ctx->dictBuffer)) {
|
||||||
DISPLAY("dictionary too large\n");
|
DISPLAY("dictionary too large\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
freeContexts(*ctx);
|
freeContexts(*ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
readSize = fread(ctx->dictBuffer, 1, ctx->dictSize, f);
|
readSize = fread(ctx->dictBuffer, 1, ctx->dictSize, f);
|
||||||
if(readSize != ctx->dictSize) {
|
fclose(f);
|
||||||
|
if (readSize != ctx->dictSize) {
|
||||||
DISPLAY("unable to read file\n");
|
DISPLAY("unable to read file\n");
|
||||||
fclose(f);
|
|
||||||
freeContexts(*ctx);
|
freeContexts(*ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fclose(f);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user