Versions mentioned in the description apply to the upstream
Remediation section below for
Debian:9 relevant versions.
jp2/opj_decompress.c in OpenJPEG through 2.3.1 has a use-after-free that can be triggered if there is a mix of valid and invalid files in a directory operated on by the decompressor. Triggering a double-free may also be possible. This is related to calling opj_image_destroy twice.
openjpeg2 to version 2.1.2-1.1+deb9u5 or higher.