File openjpeg2-CVE-2016-9116.patch of Package openjpeg2

From f18747941a1edaca1ab6e35c42a7cf818664f6b3 Mon Sep 17 00:00:00 2001
From: Hans Petter Jansson <hpj@cl.no>
Date: Wed, 14 Dec 2016 23:06:05 +0100
Subject: [PATCH 5/9] CVE-2016-9116

---
 src/bin/jp2/convert.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/bin/jp2/convert.c b/src/bin/jp2/convert.c
index 63703a8..14d9939 100644
--- a/src/bin/jp2/convert.c
+++ b/src/bin/jp2/convert.c
@@ -3130,6 +3130,11 @@ static int imagetoraw_common(opj_image_t * image, const char *outfile, OPJ_BOOL
             {
                 mask = (1 << image->comps[compno].prec) - 1;
                 ptr = image->comps[compno].data;
+                if (!ptr) {
+                    fprintf (stderr, "Missing image component data for %s\n", outfile);
+                    goto fin;
+                }
+
                 for (line = 0; line < h; line++) {
                     for(row = 0; row < w; row++)	{
                         curr = *ptr;
@@ -3148,6 +3153,11 @@ static int imagetoraw_common(opj_image_t * image, const char *outfile, OPJ_BOOL
             {
                 mask = (1 << image->comps[compno].prec) - 1;
                 ptr = image->comps[compno].data;
+                if (!ptr) {
+                    fprintf (stderr, "Missing image component data for %s\n", outfile);
+                    goto fin;
+                }
+
                 for (line = 0; line < h; line++) {
                     for(row = 0; row < w; row++)	{
                         curr = *ptr;
@@ -3170,6 +3180,11 @@ static int imagetoraw_common(opj_image_t * image, const char *outfile, OPJ_BOOL
                 union { signed short val; signed char vals[2]; } uc16;
                 mask = (1 << image->comps[compno].prec) - 1;
                 ptr = image->comps[compno].data;
+                if (!ptr) {
+                    fprintf (stderr, "Missing image component data for %s\n", outfile);
+                    goto fin;
+                }
+
                 for (line = 0; line < h; line++) {
                     for(row = 0; row < w; row++)	{
                         curr = *ptr;
@@ -3189,6 +3204,11 @@ static int imagetoraw_common(opj_image_t * image, const char *outfile, OPJ_BOOL
                 union { unsigned short val; unsigned char vals[2]; } uc16;
                 mask = (1 << image->comps[compno].prec) - 1;
                 ptr = image->comps[compno].data;
+                if (!ptr) {
+                    fprintf (stderr, "Missing image component data for %s\n", outfile);
+                    goto fin;
+                }
+
                 for (line = 0; line < h; line++) {
                     for(row = 0; row < w; row++)	{
                         curr = *ptr;
-- 
1.8.4.5