1diff --git a/third_party/libopenjpeg20/jp2.c b/third_party/libopenjpeg20/jp2.c 2index 7ef7c9139..1fa607d66 100644 3--- a/third_party/libopenjpeg20/jp2.c 4+++ b/third_party/libopenjpeg20/jp2.c 5@@ -593,6 +593,7 @@ static OPJ_BOOL opj_jp2_read_ihdr(opj_jp2_t *jp2, 6 } 7 8 /* allocate memory for components */ 9+ opj_free(jp2->comps); 10 jp2->comps = (opj_jp2_comps_t*) opj_calloc(jp2->numcomps, 11 sizeof(opj_jp2_comps_t)); 12 if (jp2->comps == 0) { 13@@ -1882,6 +1883,7 @@ void opj_jp2_setup_decoder(opj_jp2_t *jp2, opj_dparameters_t *parameters) 14 15 /* further JP2 initializations go here */ 16 jp2->color.jp2_has_colr = 0; 17+ jp2->comps = NULL; 18 jp2->ignore_pclr_cmap_cdef = parameters->flags & 19 OPJ_DPARAMETERS_IGNORE_PCLR_CMAP_CDEF_FLAG; 20 } 21