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

diff --git a/src/bin/common/color.c b/src/bin/common/color.c
index 234c7bd..f42d982 100644
--- a/src/bin/common/color.c
+++ b/src/bin/common/color.c
@@ -108,6 +108,7 @@ static void sycc444_to_rgb(opj_image_t *img)
 	d1 = g = (int*)malloc(sizeof(int) * max);
 	d2 = b = (int*)malloc(sizeof(int) * max);
 
+	if(y == NULL || cb == NULL || cr == NULL) goto fails;
 	if(r == NULL || g == NULL || b == NULL) goto fails;
 
 	for(i = 0U; i < max; ++i)
@@ -149,6 +150,7 @@ static void sycc422_to_rgb(opj_image_t *img)
 	d1 = g = (int*)malloc(sizeof(int) * max);
 	d2 = b = (int*)malloc(sizeof(int) * max);
 
+	if(y == NULL || cb == NULL || cr == NULL) goto fails;
 	if(r == NULL || g == NULL || b == NULL) goto fails;
 
 	/* if img->x0 is odd, then first column shall use Cb/Cr = 0 */
@@ -918,6 +920,7 @@ void color_esycc_to_rgb(opj_image_t *image)
 		    (image->numcomps < 3)
 		 || (image->comps[0].dx != image->comps[1].dx) || (image->comps[0].dx != image->comps[2].dx)
 		 || (image->comps[0].dy != image->comps[1].dy) || (image->comps[0].dy != image->comps[2].dy)
+		 || !image->comps [0].data || !image->comps [1].data || !image->comps [2].data
 	   ) {
 		fprintf(stderr,"%s:%d:color_esycc_to_rgb\n\tCAN NOT CONVERT\n", __FILE__,__LINE__);
 		return;
diff --git a/src/bin/jp2/convertbmp.c b/src/bin/jp2/convertbmp.c
index 4df8d58..5c52ef4 100644
--- a/src/bin/jp2/convertbmp.c
+++ b/src/bin/jp2/convertbmp.c
@@ -814,6 +814,14 @@ int imagetobmp(opj_image_t * image, const char *outfile) {
         fprintf(stderr, "Unsupported number of components: %d\n", image->comps[0].prec);
         return 1;
     }
+
+    for (i = 0; i < image->numcomps; i++) {
+        if (image->comps[i].data == NULL) {
+	    fprintf(stderr, "Missing image data\n");
+	    return 1;
+	}
+    }
+
     if (image->numcomps >= 3 && image->comps[0].dx == image->comps[1].dx
             && image->comps[1].dx == image->comps[2].dx
             && image->comps[0].dy == image->comps[1].dy