[trunk] avoid memory leak in opj_t2_decode_packets

This commit is contained in:
Mickael Savinaud 2012-11-13 09:47:16 +00:00
parent 1021e87522
commit 569d0ec7cc
1 changed files with 7 additions and 0 deletions

View File

@ -355,6 +355,11 @@ opj_bool opj_t2_decode_packets( opj_t2_t *p_t2,
* and no l_img_comp->resno_decoded are computed * and no l_img_comp->resno_decoded are computed
*/ */
opj_bool* first_pass_failed = (opj_bool*)opj_malloc(l_image->numcomps * sizeof(opj_bool)); opj_bool* first_pass_failed = (opj_bool*)opj_malloc(l_image->numcomps * sizeof(opj_bool));
if (!first_pass_failed)
{
opj_pi_destroy(l_pi,l_nb_pocs);
return OPJ_FALSE;
}
memset(first_pass_failed, OPJ_TRUE, l_image->numcomps * sizeof(opj_bool)); memset(first_pass_failed, OPJ_TRUE, l_image->numcomps * sizeof(opj_bool));
while (opj_pi_next(l_current_pi)) { while (opj_pi_next(l_current_pi)) {
@ -368,6 +373,7 @@ opj_bool opj_t2_decode_packets( opj_t2_t *p_t2,
if (! opj_t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) { if (! opj_t2_decode_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
opj_pi_destroy(l_pi,l_nb_pocs); opj_pi_destroy(l_pi,l_nb_pocs);
opj_free(first_pass_failed);
return OPJ_FALSE; return OPJ_FALSE;
} }
@ -378,6 +384,7 @@ opj_bool opj_t2_decode_packets( opj_t2_t *p_t2,
l_nb_bytes_read = 0; l_nb_bytes_read = 0;
if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) { if (! opj_t2_skip_packet(p_t2,p_tile,l_tcp,l_current_pi,l_current_data,&l_nb_bytes_read,p_max_len,l_pack_info)) {
opj_pi_destroy(l_pi,l_nb_pocs); opj_pi_destroy(l_pi,l_nb_pocs);
opj_free(first_pass_failed);
return OPJ_FALSE; return OPJ_FALSE;
} }
} }