[trunk] Correct potential double free on malloc failure in opj_j2k_copy_default_tcp_and_create_tcp (fixes issue 492)
This commit is contained in:
parent
757f9394bf
commit
0fa5a17c98
|
@ -7365,6 +7365,12 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2
|
||||||
l_tcp->cod = 0;
|
l_tcp->cod = 0;
|
||||||
l_tcp->ppt = 0;
|
l_tcp->ppt = 0;
|
||||||
l_tcp->ppt_data = 00;
|
l_tcp->ppt_data = 00;
|
||||||
|
/* Remove memory not owned by this tile in case of early error return. */
|
||||||
|
l_tcp->m_mct_decoding_matrix = 00;
|
||||||
|
l_tcp->m_nb_max_mct_records = 0;
|
||||||
|
l_tcp->m_mct_records = 00;
|
||||||
|
l_tcp->m_nb_max_mcc_records = 0;
|
||||||
|
l_tcp->m_mcc_records = 00;
|
||||||
/* Reconnect the tile-compo coding parameters pointer to the current tile coding parameters*/
|
/* Reconnect the tile-compo coding parameters pointer to the current tile coding parameters*/
|
||||||
l_tcp->tccps = l_current_tccp;
|
l_tcp->tccps = l_current_tccp;
|
||||||
|
|
||||||
|
@ -7402,6 +7408,8 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2
|
||||||
|
|
||||||
++l_src_mct_rec;
|
++l_src_mct_rec;
|
||||||
++l_dest_mct_rec;
|
++l_dest_mct_rec;
|
||||||
|
/* Update with each pass to free exactly what has been allocated on early return. */
|
||||||
|
l_tcp->m_nb_max_mct_records += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the mcc_record of the dflt_tile_cp and copy them into the current tile cp*/
|
/* Get the mcc_record of the dflt_tile_cp and copy them into the current tile cp*/
|
||||||
|
@ -7411,6 +7419,7 @@ static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2
|
||||||
return OPJ_FALSE;
|
return OPJ_FALSE;
|
||||||
}
|
}
|
||||||
memcpy(l_tcp->m_mcc_records,l_default_tcp->m_mcc_records,l_mcc_records_size);
|
memcpy(l_tcp->m_mcc_records,l_default_tcp->m_mcc_records,l_mcc_records_size);
|
||||||
|
l_tcp->m_nb_max_mcc_records = l_default_tcp->m_nb_max_mcc_records;
|
||||||
|
|
||||||
/* Copy the mcc record data from dflt_tile_cp to the current tile*/
|
/* Copy the mcc record data from dflt_tile_cp to the current tile*/
|
||||||
l_src_mcc_rec = l_default_tcp->m_mcc_records;
|
l_src_mcc_rec = l_default_tcp->m_mcc_records;
|
||||||
|
|
Loading…
Reference in New Issue