fixed wrong size in pthread struct transfer

This commit is contained in:
Yann Collet 2018-06-19 20:14:03 -07:00
parent 166901dc72
commit 62469c9f41
2 changed files with 8 additions and 9 deletions

View File

@ -196,19 +196,18 @@ static POOL_ctx* POOL_resize_internal(POOL_ctx* ctx, size_t numThreads)
{ ZSTD_pthread_t* const threadPool = (ZSTD_pthread_t*)ZSTD_malloc(numThreads * sizeof(ZSTD_pthread_t), ctx->customMem);
if (!threadPool) return NULL;
/* replace existing thread pool */
memcpy(threadPool, ctx->threads, ctx->threadCapacity);
memcpy(threadPool, ctx->threads, ctx->threadCapacity * sizeof(ctx->threads[0]));
ZSTD_free(ctx->threads, ctx->customMem);
ctx->threads = threadPool;
/* Initialize additional threads */
{ size_t threadId;
for (threadId = ctx->threadCapacity; threadId < numThreads; ++threadId) {
if (ZSTD_pthread_create(&threadPool[threadId], NULL, &POOL_thread, ctx)) {
break;
ctx->threadCapacity = threadId;
ctx->threadLimit = threadId;
return NULL; /* will release the pool */
} }
if (threadId != numThreads) { /* not all threads successfully init */
ctx->threadCapacity = threadId;
return NULL; /* will release the pool */
} } }
} }
/* successfully expanded */
ctx->threadCapacity = numThreads;
ctx->threadLimit = numThreads;

View File

@ -1643,13 +1643,13 @@ static int fuzzerTests_newAPI(U32 seed, U32 nbTests, unsigned startTest, double
DISPLAYLEVEL(5, "Creating new context \n");
ZSTD_freeCCtx(zc);
zc = ZSTD_createCCtx();
CHECK(zc==NULL, "ZSTD_createCCtx allocation error");
resetAllowed=0;
CHECK(zc == NULL, "ZSTD_createCCtx allocation error");
resetAllowed = 0;
}
if ((FUZ_rand(&lseed) & 0xFF) == 132) {
ZSTD_freeDStream(zd);
zd = ZSTD_createDStream();
CHECK(zd==NULL, "ZSTD_createDStream allocation error");
CHECK(zd == NULL, "ZSTD_createDStream allocation error");
ZSTD_initDStream_usingDict(zd, NULL, 0); /* ensure at least one init */
}