@@ -1059,6 +1059,10 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
1059
1059
gdImagePtr tmp_im ;
1060
1060
gdImagePtr dst ;
1061
1061
1062
+ if (new_width == 0 || new_height == 0 ) {
1063
+ return NULL ;
1064
+ }
1065
+
1062
1066
/* Convert to truecolor if it isn't; this code requires it. */
1063
1067
if (!src -> trueColor ) {
1064
1068
gdImagePaletteToTrueColor (src );
@@ -1087,6 +1091,10 @@ gdImagePtr Scale(const gdImagePtr src, const unsigned int src_width, const unsig
1087
1091
{
1088
1092
gdImagePtr tmp_im ;
1089
1093
1094
+ if (new_width == 0 || new_height == 0 ) {
1095
+ return NULL ;
1096
+ }
1097
+
1090
1098
tmp_im = gdImageCreateTrueColor (new_width , src_height );
1091
1099
if (tmp_im == NULL ) {
1092
1100
return NULL ;
@@ -1120,6 +1128,10 @@ gdImagePtr gdImageScaleNearestNeighbour(gdImagePtr im, const unsigned int width,
1120
1128
unsigned long dst_offset_y = 0 ;
1121
1129
unsigned int i ;
1122
1130
1131
+ if (new_width == 0 || new_height == 0 ) {
1132
+ return NULL ;
1133
+ }
1134
+
1123
1135
dst_img = gdImageCreateTrueColor (new_width , new_height );
1124
1136
1125
1137
if (dst_img == NULL ) {
@@ -1221,6 +1233,10 @@ static gdImagePtr gdImageScaleBilinearPalette(gdImagePtr im, const unsigned int
1221
1233
gdImagePtr new_img ;
1222
1234
const int transparent = im -> transparent ;
1223
1235
1236
+ if (new_width == 0 || new_height == 0 ) {
1237
+ return NULL ;
1238
+ }
1239
+
1224
1240
new_img = gdImageCreateTrueColor (new_width , new_height );
1225
1241
if (new_img == NULL ) {
1226
1242
return NULL ;
@@ -1313,6 +1329,10 @@ static gdImagePtr gdImageScaleBilinearTC(gdImagePtr im, const unsigned int new_w
1313
1329
long i ;
1314
1330
gdImagePtr new_img ;
1315
1331
1332
+ if (new_width == 0 || new_height == 0 ) {
1333
+ return NULL ;
1334
+ }
1335
+
1316
1336
new_img = gdImageCreateTrueColor (new_width , new_height );
1317
1337
if (!new_img ){
1318
1338
return NULL ;
@@ -1412,6 +1432,10 @@ gdImagePtr gdImageScaleBicubicFixed(gdImagePtr src, const unsigned int width, co
1412
1432
unsigned int dst_offset_y = 0 ;
1413
1433
long i ;
1414
1434
1435
+ if (new_width == 0 || new_height == 0 ) {
1436
+ return NULL ;
1437
+ }
1438
+
1415
1439
/* impact perf a bit, but not that much. Implementation for palette
1416
1440
images can be done at a later point.
1417
1441
*/
@@ -1634,7 +1658,11 @@ gdImagePtr gdImageScale(const gdImagePtr src, const unsigned int new_width, cons
1634
1658
gdImagePtr im_scaled = NULL ;
1635
1659
1636
1660
if (src == NULL || src -> interpolation_id < 0 || src -> interpolation_id > GD_METHOD_COUNT ) {
1637
- return 0 ;
1661
+ return NULL ;
1662
+ }
1663
+
1664
+ if (new_width == 0 || new_height == 0 ) {
1665
+ return NULL ;
1638
1666
}
1639
1667
1640
1668
switch (src -> interpolation_id ) {
@@ -1680,6 +1708,10 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, co
1680
1708
unsigned int i ;
1681
1709
gdImagePtr dst ;
1682
1710
1711
+ if (new_width == 0 || new_height == 0 ) {
1712
+ return NULL ;
1713
+ }
1714
+
1683
1715
dst = gdImageCreateTrueColor (new_width , new_height );
1684
1716
if (!dst ) {
1685
1717
return NULL ;
0 commit comments