PDF: fix crashes in openjpeg code