Fix resource leak in opj_j2k_encode
authormayeut <mayeut@users.noreply.github.com>
Thu, 17 Sep 2015 10:41:41 +0000 (12:41 +0200)
committermayeut <mayeut@users.noreply.github.com>
Thu, 17 Sep 2015 10:41:41 +0000 (12:41 +0200)
Fixes #598

src/lib/openjp2/j2k.c

index e733c6457202d3f53361c0972637a0ef5d61014b..ec3635b6e8cb550a4b3019f999fff79923a4362a 100644 (file)
@@ -9999,11 +9999,15 @@ OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k,
                         /* now copy this data into the tile component */
                         if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,l_current_data,l_current_tile_size)) {
                                                                                                                                opj_event_msg(p_manager, EVT_ERROR, "Size mismatch between tile data and sent data." );
+                                                                                                                               opj_free(l_current_data);
                                                                                                                                return OPJ_FALSE;
                         }
                 }
 
                 if (! opj_j2k_post_write_tile (p_j2k,p_stream,p_manager)) {
+                        if (l_current_data) {
+                                opj_free(l_current_data);
+                        }
                         return OPJ_FALSE;
                 }
         }