diff --git a/third_party/libopenjpeg20/jp2.c b/third_party/libopenjpeg20/jp2.c
index 298648a77..2374d459f 100644
--- a/third_party/libopenjpeg20/jp2.c
+++ b/third_party/libopenjpeg20/jp2.c
@@ -1116,7 +1116,7 @@ static OPJ_BOOL opj_jp2_apply_pclr(opj_image_t *image,
         /* Prevent null pointer access */
         if (!src || !dst) {
           for (j = 0; j < nr_channels; ++j) {
-            opj_free(new_comps[j].data);
+            opj_image_data_free(new_comps[j].data);
           }
           opj_free(new_comps);
           new_comps = NULL;