@@ -1720,38 +1720,35 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
1720
1720
{
1721
1721
zval * imgind ;
1722
1722
char * file = NULL ;
1723
- zend_long quality = 0 , type = 0 ;
1723
+ zend_long quality = 128 , type = 1 ;
1724
1724
gdImagePtr im ;
1725
1725
FILE * fp ;
1726
1726
size_t file_len = 0 ;
1727
- int argc = ZEND_NUM_ARGS ();
1728
- int q = -1 , t = 1 ;
1729
1727
1730
1728
/* The quality parameter for gd2 stands for chunk size */
1731
1729
1732
1730
switch (image_type ) {
1733
1731
case PHP_GDIMG_TYPE_GD :
1734
- if (zend_parse_parameters (argc , "O|p!" , & imgind , gd_image_ce , & file , & file_len ) == FAILURE ) {
1732
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "O|p!" , & imgind , gd_image_ce , & file , & file_len ) == FAILURE ) {
1735
1733
RETURN_THROWS ();
1736
1734
}
1737
1735
break ;
1738
1736
case PHP_GDIMG_TYPE_GD2 :
1739
- if (zend_parse_parameters (argc , "O|p!ll" , & imgind , gd_image_ce , & file , & file_len , & quality , & type ) == FAILURE ) {
1737
+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "O|p!ll" , & imgind , gd_image_ce , & file , & file_len , & quality , & type ) == FAILURE ) {
1740
1738
RETURN_THROWS ();
1741
1739
}
1742
1740
break ;
1743
1741
EMPTY_SWITCH_DEFAULT_CASE ()
1744
1742
}
1745
1743
1746
- im = php_gd_libgdimageptr_from_zval_p (imgind );
1747
-
1748
- if (argc >= 3 ) {
1749
- q = quality ;
1750
- if (argc == 4 ) {
1751
- t = type ;
1752
- }
1744
+ /* quality must fit in an int */
1745
+ if (quality < INT_MIN || quality > INT_MAX ) {
1746
+ php_error_docref (NULL , E_WARNING , "Argument #3 ($chunk_size) must be between %d and %d" , INT_MIN , INT_MAX );
1747
+ RETURN_FALSE ;
1753
1748
}
1754
1749
1750
+ im = php_gd_libgdimageptr_from_zval_p (imgind );
1751
+
1755
1752
if (file_len ) {
1756
1753
PHP_GD_CHECK_OPEN_BASEDIR (file , "Invalid filename" );
1757
1754
@@ -1766,10 +1763,10 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
1766
1763
gdImageGd (im , fp );
1767
1764
break ;
1768
1765
case PHP_GDIMG_TYPE_GD2 :
1769
- if (q == -1 ) {
1770
- q = 128 ;
1766
+ if (quality == -1 ) {
1767
+ quality = 128 ;
1771
1768
}
1772
- gdImageGd2 (im , fp , q , t );
1769
+ gdImageGd2 (im , fp , quality , type );
1773
1770
break ;
1774
1771
EMPTY_SWITCH_DEFAULT_CASE ()
1775
1772
}
@@ -1792,10 +1789,10 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
1792
1789
gdImageGd (im , tmp );
1793
1790
break ;
1794
1791
case PHP_GDIMG_TYPE_GD2 :
1795
- if (q == -1 ) {
1796
- q = 128 ;
1792
+ if (quality == -1 ) {
1793
+ quality = 128 ;
1797
1794
}
1798
- gdImageGd2 (im , tmp , q , t );
1795
+ gdImageGd2 (im , tmp , quality , type );
1799
1796
break ;
1800
1797
EMPTY_SWITCH_DEFAULT_CASE ()
1801
1798
}
0 commit comments