diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 093daeac4199..938672ccc0c7 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -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 */ @@ -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; diff --git a/ext/gd/tests/imagecreatefromstring.wbmp b/ext/gd/tests/imagecreatefromstring.wbmp new file mode 100644 index 000000000000..f1af776b7f20 Binary files /dev/null and b/ext/gd/tests/imagecreatefromstring.wbmp differ diff --git a/ext/gd/tests/imagecreatefromstring_wbmp.phpt b/ext/gd/tests/imagecreatefromstring_wbmp.phpt new file mode 100644 index 000000000000..07bf3f7e196d --- /dev/null +++ b/ext/gd/tests/imagecreatefromstring_wbmp.phpt @@ -0,0 +1,19 @@ +--TEST-- +imagecreatefromstring() - WBMP format +--EXTENSIONS-- +gd +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(200) +int(200)