Skip to content

Commit

Permalink
openjp2: Plug memory leak when setting data as TLS fails.
Browse files Browse the repository at this point in the history
Previously the Tier 1 handle was not freed when setting it as
TLS failed.

This fixes issue #1257.
  • Loading branch information
sebras committed Jun 22, 2020
1 parent 25fb144 commit 14fc5b6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/openjp2/t1.c
Expand Up @@ -1658,7 +1658,14 @@ static void opj_t1_clbl_decode_processor(void* user_data, opj_tls_t* tls)
t1 = (opj_t1_t*) opj_tls_get(tls, OPJ_TLS_KEY_T1);
if (t1 == NULL) {
t1 = opj_t1_create(OPJ_FALSE);
opj_tls_set(tls, OPJ_TLS_KEY_T1, t1, opj_t1_destroy_wrapper);
if (!opj_tls_set(tls, OPJ_TLS_KEY_T1, t1, opj_t1_destroy_wrapper)) {
opj_event_msg(job->p_manager, EVT_ERROR,
"Unable to set t1 handle as TLS\n");
opj_t1_destroy(t1);
*(job->pret) = OPJ_FALSE;
opj_free(job);
return;
}
}
t1->mustuse_cblkdatabuffer = job->mustuse_cblkdatabuffer;

Expand Down

0 comments on commit 14fc5b6

Please sign in to comment.