Be robust to failed allocations of job structures

This commit is contained in:
Even Rouault 2016-05-26 23:51:32 +02:00
parent 69497d35c0
commit 7d3c7a345f
2 changed files with 25 additions and 0 deletions

View File

@ -679,6 +679,16 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* t
opj_dwd_decode_h_job_t* job;
job = (opj_dwd_decode_h_job_t*) opj_malloc(sizeof(opj_dwd_decode_h_job_t));
if( !job )
{
/* It would be nice to fallback to single thread case, but */
/* unfortunately some jobs may be launched and have modified */
/* tiledp, so it is not practical to recover from that error */
/* FIXME event manager error callback */
opj_thread_pool_wait_completion(tp, 0);
opj_aligned_free(h.mem);
return OPJ_FALSE;
}
job->h = h;
job->dwt_1D = dwt_1D;
job->rw = rw;
@ -726,6 +736,16 @@ static OPJ_BOOL opj_dwt_decode_tile(opj_thread_pool_t* tp, opj_tcd_tilecomp_t* t
opj_dwd_decode_v_job_t* job;
job = (opj_dwd_decode_v_job_t*) opj_malloc(sizeof(opj_dwd_decode_v_job_t));
if( !job )
{
/* It would be nice to fallback to single thread case, but */
/* unfortunately some jobs may be launched and have modified */
/* tiledp, so it is not practical to recover from that error */
/* FIXME event manager error callback */
opj_thread_pool_wait_completion(tp, 0);
opj_aligned_free(v.mem);
return OPJ_FALSE;
}
job->v = v;
job->dwt_1D = dwt_1D;
job->rh = rh;

View File

@ -1689,6 +1689,11 @@ void opj_t1_decode_cblks( opj_thread_pool_t* tp,
opj_t1_cblk_decode_processing_job_t* job;
job = (opj_t1_cblk_decode_processing_job_t*) opj_calloc(1, sizeof(opj_t1_cblk_decode_processing_job_t));
if( !job )
{
*pret = OPJ_FALSE;
return;
}
job->resno = resno;
job->cblk = cblk;
job->band = band;