Description: fix denial of service and possible code execution
Origin: based on http://git.php.net/?p=php-src.git;a=commit;h=46df0642618eabc5b5b7df490d1ae23bda00a745
Bug: https://github.com/libgd/libgd/issues/308

Index: libgd2-2.1.1/src/gd_webp.c
===================================================================
--- libgd2-2.1.1.orig/src/gd_webp.c	2015-01-13 22:09:04.000000000 -0500
+++ libgd2-2.1.1/src/gd_webp.c	2016-10-06 10:40:53.394331583 -0400
@@ -179,6 +179,15 @@
 	/* Conversion to Y,U,V buffer */
 	yuv_width = (width + 1) >> 1;
 	yuv_height = (height + 1) >> 1;
+
+	if (overflow2(width, height)) {
+		return;
+	}
+	/* simplification possible, because WebP must not be larger than 16384**2 */
+	if (overflow2(width * height, 2 * sizeof(unsigned char))) {
+		return;
+	}
+
 	yuv_nbytes = width * height + 2 * yuv_width * yuv_height;
 
 	if ((Y = (unsigned char *)gdCalloc(yuv_nbytes, sizeof(unsigned char))) == NULL) {
