diff options
author | Aaron Piotrowski <aaron@trowski.com> | 2016-07-03 22:42:10 -0500 |
---|---|---|
committer | Aaron Piotrowski <aaron@trowski.com> | 2016-07-03 22:42:10 -0500 |
commit | d9a9cf8ecaef891b2369969e9efe9f6261359158 (patch) | |
tree | 04bcc83b3c9be1924007e007e1f508f7229af7ab /ext/gd/libgd/gd_interpolation.c | |
parent | 583386d59e6b362fe49e51594718a109d0c0cc2f (diff) | |
parent | c2b29a58bc0916e248ba2584564558097b16b51f (diff) | |
download | php-git-d9a9cf8ecaef891b2369969e9efe9f6261359158.tar.gz |
Merge branch 'master' into iterable
Diffstat (limited to 'ext/gd/libgd/gd_interpolation.c')
-rw-r--r-- | ext/gd/libgd/gd_interpolation.c | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index cf67ec9b46..83319966f9 100644 --- a/ext/gd/libgd/gd_interpolation.c +++ b/ext/gd/libgd/gd_interpolation.c @@ -1047,6 +1047,9 @@ static inline void _gdScaleVert (const gdImagePtr pSrc, const unsigned int src_w } contrib = _gdContributionsCalc(dst_height, src_height, (double)(dst_height) / (double)(src_height), pSrc->interpolation); + if (contrib == NULL) { + return; + } /* scale each column */ for (u = 0; u < dst_width - 1; u++) { _gdScaleCol(pSrc, src_width, pDst, dst_width, dst_height, u, contrib); @@ -1059,6 +1062,10 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt gdImagePtr tmp_im; gdImagePtr dst; + if (new_width == 0 || new_height == 0) { + return NULL; + } + /* Convert to truecolor if it isn't; this code requires it. */ if (!src->trueColor) { gdImagePaletteToTrueColor(src); @@ -1087,6 +1094,10 @@ gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsig { gdImagePtr tmp_im; + if (new_width == 0 || new_height == 0) { + return NULL; + } + tmp_im = gdImageCreateTrueColor(new_width, src_height); if (tmp_im == NULL) { return NULL; @@ -1120,6 +1131,10 @@ gdImagePtr gdImageScaleNearestNeighbour(gdImagePtr im, const unsigned int width, unsigned long dst_offset_y = 0; unsigned int i; + if (new_width == 0 || new_height == 0) { + return NULL; + } + dst_img = gdImageCreateTrueColor(new_width, new_height); if (dst_img == NULL) { @@ -1221,6 +1236,10 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int gdImagePtr new_img; const int transparent = im->transparent; + if (new_width == 0 || new_height == 0) { + return NULL; + } + new_img = gdImageCreateTrueColor(new_width, new_height); if (new_img == NULL) { return NULL; @@ -1313,6 +1332,10 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w long i; gdImagePtr new_img; + if (new_width == 0 || new_height == 0) { + return NULL; + } + new_img = gdImageCreateTrueColor(new_width, new_height); if (!new_img){ return NULL; @@ -1412,6 +1435,10 @@ gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, co unsigned int dst_offset_y = 0; long i; + if (new_width == 0 || new_height == 0) { + return NULL; + } + /* impact perf a bit, but not that much. Implementation for palette images can be done at a later point. */ @@ -1634,7 +1661,11 @@ gdImagePtr gdImageScale(const gdImagePtr src, const unsigned int new_width, cons gdImagePtr im_scaled = NULL; if (src == NULL || src->interpolation_id < 0 || src->interpolation_id > GD_METHOD_COUNT) { - return 0; + return NULL; + } + + if (new_width == 0 || new_height == 0) { + return NULL; } switch (src->interpolation_id) { @@ -1680,6 +1711,10 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, co unsigned int i; gdImagePtr dst; + if (new_width == 0 || new_height == 0) { + return NULL; + } + dst = gdImageCreateTrueColor(new_width, new_height); if (!dst) { return NULL; |