This commit is contained in:
Rohith Matam 2026-08-03 13:18:19 +02:00 committed by GitHub
commit 08c080afb4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View file

@ -638,9 +638,10 @@ static size_t COVER_ctx_init(COVER_ctx_t *ctx, const void *samplesBuffer,
const size_t testSamplesSize = splitPoint < 1.0 ? COVER_sum(samplesSizes + nbTrainSamples, nbTestSamples) : totalSamplesSize;
ctx->displayLevel = displayLevel;
/* Checks */
if (totalSamplesSize < MAX(d, sizeof(U64)) ||
if (trainingSamplesSize < MAX(d, sizeof(U64)) ||
totalSamplesSize < MAX(d, sizeof(U64)) ||
totalSamplesSize >= (size_t)COVER_MAX_SAMPLES_SIZE) {
DISPLAYLEVEL(1, "Total samples size is too large (%u MB), maximum size is %u MB\n",
DISPLAYLEVEL(1, "Total samples size is too small or too large (%u MB), maximum size is %u MB\n",
(unsigned)(totalSamplesSize>>20), (COVER_MAX_SAMPLES_SIZE >> 20));
return ERROR(srcSize_wrong);
}

View file

@ -3807,6 +3807,25 @@ static int basicUnitTests(U32 const seed, double compressibility)
if (ZDICT_isError(optDictSize)) goto _output_error;
DISPLAYLEVEL(3, "OK, created dictionary of size %u \n", (unsigned)optDictSize);
DISPLAYLEVEL(3, "test%3i : ZDICT_optimizeTrainFromBuffer_cover with tiny training set : ", testNb++);
{ BYTE tinySamples[10];
size_t tinySampleSizes[10];
size_t result;
U32 u;
for (u=0; u<10; u++) {
tinySamples[u] = (BYTE)u;
tinySampleSizes[u] = 1;
}
memset(&params, 0, sizeof(params));
params.splitPoint = 0.5;
result = ZDICT_optimizeTrainFromBuffer_cover(dictBuffer, optDictSize,
tinySamples, tinySampleSizes,
10, &params);
if (!ZDICT_isError(result)) goto _output_error;
if (ZSTD_getErrorCode(result) != ZSTD_error_srcSize_wrong) goto _output_error;
}
DISPLAYLEVEL(3, "OK \n");
DISPLAYLEVEL(3, "test%3i : check dictID : ", testNb++);
dictID = ZDICT_getDictID(dictBuffer, optDictSize);
if (dictID==0) goto _output_error;