Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 2 additions & 27 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1358,24 +1358,6 @@ PHP_FUNCTION(imagetypes)
}
/* }}} */

/* {{{ _php_ctx_getmbi */

static int _php_ctx_getmbi(gdIOCtx *ctx)
{
int i, mbi = 0;

do {
i = (ctx->getC)(ctx);
if (i < 0 || mbi > (INT_MAX >> 7)) {
return -1;
}
mbi = (mbi << 7) | (i & 0x7f);
} while (i & 0x80);

return mbi;
}
/* }}} */

/* {{{ _php_image_type
* Based on ext/standard/image.c
*/
Expand Down Expand Up @@ -1413,15 +1395,8 @@ static int _php_image_type(zend_string *data)
}
}

gdIOCtx *io_ctx;
io_ctx = gdNewDynamicCtxEx(8, ZSTR_VAL(data), 0);
if (io_ctx) {
if (_php_ctx_getmbi(io_ctx) == 0 && _php_ctx_getmbi(io_ctx) >= 0) {
io_ctx->gd_free(io_ctx);
return PHP_GDIMG_TYPE_WBM;
} else {
io_ctx->gd_free(io_ctx);
}
if (ZSTR_VAL(data)[0] == 0) {
return PHP_GDIMG_TYPE_WBM;
}

return -1;
Expand Down
Binary file added ext/gd/tests/imagecreatefromstring.wbmp
Binary file not shown.
19 changes: 19 additions & 0 deletions ext/gd/tests/imagecreatefromstring_wbmp.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
imagecreatefromstring() - WBMP format
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (!(imagetypes() & IMG_WBMP)) die('skip GIF support required');
?>
--FILE--
<?php
// create an image from a WBMP string representation
$im = imagecreatefromstring(file_get_contents(__DIR__ . '/imagecreatefromstring.wbmp'));
var_dump(imagesx($im));
var_dump(imagesy($im));

?>
--EXPECT--
int(200)
int(200)