Skip to content

Commit 8f97f82

Browse files
Blacksmoke16nikic
authored andcommitted
Fix bug #81265: getimagesize returns 0 for 256px ICO images
Set ICO height/width to 256 if 0.
1 parent a054ef2 commit 8f97f82

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ PHP NEWS
1010

1111
- Standard:
1212
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)
13+
. Fixed bug #81265 (getimagesize returns 0 for 256px ICO images).
14+
(George Dietrich)
1315

1416
29 Jul 2021, PHP 7.4.22
1517

ext/standard/image.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,12 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
11161116
num_icons--;
11171117
}
11181118

1119+
if (0 == result->width)
1120+
result->width = 256;
1121+
1122+
if (0 == result->height)
1123+
result->height = 256;
1124+
11191125
return result;
11201126
}
11211127
/* }}} */

ext/standard/tests/image/32x256.ico

10.1 KB
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GetImageSize() for ico format with 256px height
3+
--FILE--
4+
<?php
5+
echo "*** Testing getimagesize() : 256px ico ***\n";
6+
var_dump(getimagesize(__DIR__ . "/32x256.ico"));
7+
8+
?>
9+
===DONE===
10+
--EXPECT--
11+
*** Testing getimagesize() : 256px ico ***
12+
array(6) {
13+
[0]=>
14+
int(32)
15+
[1]=>
16+
int(256)
17+
[2]=>
18+
int(17)
19+
[3]=>
20+
string(23) "width="32" height="256""
21+
["bits"]=>
22+
int(8)
23+
["mime"]=>
24+
string(24) "image/vnd.microsoft.icon"
25+
}
26+
===DONE===

0 commit comments

Comments
 (0)