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