summaryrefslogtreecommitdiff
path: root/example.c
diff options
context:
space:
mode:
authorGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2017-04-22 15:30:52 -0500
committerGlenn Randers-Pehrson <glennrp at users.sourceforge.net>2017-04-22 15:46:59 -0500
commit2eff8ef5042d432d00064f7612a579cf5aff09bb (patch)
tree0c35245d92a5b8b8310d7a20ba902856c80c67cd /example.c
parent60d8ae100307770ecd5f168e47bcb3ff6683480a (diff)
downloadlibpng-2eff8ef5042d432d00064f7612a579cf5aff09bb.tar.gz
[libpng16] Imported from libpng-1.6.30beta02.tarv1.6.30beta02
Diffstat (limited to 'example.c')
-rw-r--r--example.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/example.c b/example.c
index edc8ba2d9..a71000fa0 100644
--- a/example.c
+++ b/example.c
@@ -983,6 +983,11 @@ void write_png(char *file_name /* , ... other image information ... */)
png_uint_32 k, height, width;
/* In this example, "image" is a one-dimensional array of bytes */
+
+ /* Guard against integer overflow */
+ if (height > PNG_SIZE_MAX/(width*bytes_per_pixel)) {
+ png_error(png_ptr, "Image_data buffer would be too large");
+ }
png_byte image[height*width*bytes_per_pixel];
png_bytep row_pointers[height];