Fix leak in jp2_read_header_procedure() (from even.rouault, see issue 29 on googlecode)

This commit is contained in:
Antonin Descampe 2010-11-25 12:15:07 +00:00
parent cc01949777
commit a916dcd052
2 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed ! : changed
+ : added + : added
November 25, 2010
* [antonin] Fix leak in jp2_read_header_procedure() (from even.rouault, see issue 29 on googlecode)
Jun 22, 2010 Jun 22, 2010
+ [MM] Import j2k_dump from trunk (much faster!) + [MM] Import j2k_dump from trunk (much faster!)

View File

@ -525,11 +525,13 @@ bool jp2_read_header_procedure(
(jp2->jp2_state & JP2_STATE_HEADER) (jp2->jp2_state & JP2_STATE_HEADER)
{ {
jp2->jp2_state |= JP2_STATE_CODESTREAM; jp2->jp2_state |= JP2_STATE_CODESTREAM;
opj_free(l_current_data);
return true; return true;
} }
else else
{ {
opj_event_msg(p_manager, EVT_ERROR, "bad placed jpeg codestream\n"); opj_event_msg(p_manager, EVT_ERROR, "bad placed jpeg codestream\n");
opj_free(l_current_data);
return false; return false;
} }
} }
@ -537,6 +539,7 @@ bool jp2_read_header_procedure(
(box.length == 0) (box.length == 0)
{ {
opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n"); opj_event_msg(p_manager, EVT_ERROR, "Cannot handle box of undefined sizes\n");
opj_free(l_current_data);
return false; return false;
} }
@ -562,6 +565,7 @@ bool jp2_read_header_procedure(
if if
(! l_current_handler->handler(jp2,l_current_data,l_current_data_size,p_manager)) (! l_current_handler->handler(jp2,l_current_data,l_current_data_size,p_manager))
{ {
opj_free(l_current_data);
return false; return false;
} }
} }
@ -572,10 +576,14 @@ bool jp2_read_header_procedure(
(opj_stream_skip(cio,l_current_data_size,p_manager) != l_current_data_size) (opj_stream_skip(cio,l_current_data_size,p_manager) != l_current_data_size)
{ {
opj_event_msg(p_manager, EVT_ERROR, "Problem with skipping JPEG2000 box, stream error\n"); opj_event_msg(p_manager, EVT_ERROR, "Problem with skipping JPEG2000 box, stream error\n");
opj_free(l_current_data);
return false; return false;
} }
} }
} }
opj_free(l_current_data);
return true; return true;
} }