Merge pull request #975 from szukw000/changes-for-afl-tests
[openjpeg.git] / src / bin / jp2 / opj_decompress.c
index 3dc651ddcbfbce35b099a5a60249f2955df45d72..e2d8cbde85906d0be6962b201cc062a66f16f5ea 100644 (file)
@@ -1489,6 +1489,17 @@ int main(int argc, char **argv)
             }
         }
 
+        /* FIXME? Shouldn't that situation be considered as an error of */
+        /* opj_decode() / opj_get_decoded_tile() ? */
+        if (image->comps[0].data == NULL) {
+            fprintf(stderr, "ERROR -> opj_decompress: no image data!\n");
+            opj_destroy_codec(l_codec);
+            opj_stream_destroy(l_stream);
+            opj_image_destroy(image);
+            failed = 1;
+            goto fin;
+        }
+
         tCumulative += opj_clock() - t;
         numDecompressedImages++;
 
@@ -1711,7 +1722,7 @@ fin:
         }
         free(dirptr);
     }
-    if (numDecompressedImages && !(parameters.quiet)) {
+    if (numDecompressedImages && !failed && !(parameters.quiet)) {
         fprintf(stdout, "decode time: %d ms\n",
                 (int)((tCumulative * 1000.0) / (OPJ_FLOAT64)numDecompressedImages));
     }