Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e42bdcb7aa | ||
|
|
49fc016eb9 | ||
|
|
7de5c80d14 | ||
|
|
06721070a4 | ||
|
|
28ed09929c | ||
|
|
03df764d1c | ||
|
|
211f30c2c8 | ||
|
|
2119b0d41d | ||
|
|
6a544f2d1e | ||
|
|
1f5412982c | ||
|
|
40b8105cca | ||
|
|
99bf19c177 | ||
|
|
4f0960a800 | ||
|
|
66baefec44 | ||
|
|
c696bc8cfa | ||
|
|
c596b02a5b | ||
|
|
8f5eda4bf6 | ||
|
|
709731797c | ||
|
|
c7936ead8f | ||
|
|
1da79a6c6e | ||
|
|
075aa911ff | ||
|
|
28887fe41b | ||
|
|
f9a699f6c3 | ||
|
|
9a2a45c1df | ||
|
|
a22175b06f | ||
|
|
807004a446 | ||
|
|
726c5999eb | ||
|
|
49c3fa43ad | ||
|
|
4397306b32 | ||
|
|
4dd70b6e2f | ||
|
|
fc2cadca2d | ||
|
|
56fa36b0a8 | ||
|
|
1ed4b13fb6 | ||
|
|
6682673070 | ||
|
|
01c7c6b152 | ||
|
|
ac07008bb7 | ||
|
|
46df064261 | ||
|
|
3c117d4136 | ||
|
|
55237fe153 | ||
|
|
1d7484077a | ||
|
|
7bfb7b62b1 | ||
|
|
36df4f8419 | ||
|
|
09eb6ed35e | ||
|
|
05baa92727 | ||
|
|
c43ecfd798 | ||
|
|
248f8c3a91 | ||
|
|
fc31d6fed4 | ||
|
|
8fd0e0285f | ||
|
|
363c2524dd | ||
|
|
28f80baf3c | ||
|
|
33d0ef0fef | ||
|
|
c4cca4c20e | ||
|
|
f5a9592ad8 | ||
|
|
6a7cc8ff85 | ||
|
|
7381d4c00e | ||
|
|
ecb7f58a06 | ||
|
|
b88393f08a | ||
|
|
65c8caafa8 | ||
|
|
6d55ba2656 | ||
|
|
ba5ac0d360 | ||
|
|
223266e4e4 | ||
|
|
19866fb76c | ||
|
|
39f45e208c | ||
|
|
0cbf634657 | ||
|
|
fcdc30b347 | ||
|
|
6d0e773292 | ||
|
|
6ef987e012 | ||
|
|
38455293f7 | ||
|
|
dc09f30933 | ||
|
|
326a4e38fb | ||
|
|
6c9d37d059 | ||
|
|
669fda00b7 | ||
|
|
c42a7f2f3f | ||
|
|
23e721fc93 | ||
|
|
cb91a51b00 | ||
|
|
38553e853b | ||
|
|
b1f33db39f | ||
|
|
8c700076d7 | ||
|
|
fb1c46f013 | ||
|
|
8bbd0952e5 | ||
|
|
5880428dac | ||
|
|
dad793630d | ||
|
|
3a35d43ad9 | ||
|
|
a25f6f89cd | ||
|
|
8aad3131a1 | ||
|
|
dd6da58fac | ||
|
|
0045d16863 | ||
|
|
b92cb6b238 | ||
|
|
1abbcc8cc5 | ||
|
|
9834978a8b | ||
|
|
5c38fbe543 | ||
|
|
39423e425d | ||
|
|
cee363d609 | ||
|
|
84d495055d | ||
|
|
b578580e88 | ||
|
|
d1fbc98ff6 | ||
|
|
b7259b71b4 | ||
|
|
d582241368 | ||
|
|
9513187dee | ||
|
|
bca913d70a | ||
|
|
c83bdb8e6a | ||
|
|
5efd2a33df | ||
|
|
e576714f6b | ||
|
|
fbb81dd755 | ||
|
|
b2d267d9ee | ||
|
|
314a9f8553 | ||
|
|
747b61808b | ||
|
|
2f10db36af | ||
|
|
af7828a20f | ||
|
|
207dab585a | ||
|
|
c7b4cd1a51 | ||
|
|
ae81e8fc32 | ||
|
|
d787b0ea13 | ||
|
|
295303b590 | ||
|
|
1a840b9af0 | ||
|
|
e2609a38d9 | ||
|
|
c73bcbefbd | ||
|
|
2139918ea6 | ||
|
|
84512a1177 | ||
|
|
bd8112afe0 | ||
|
|
a1ff39ffe5 | ||
|
|
6a232c3604 | ||
|
|
d65adac2be | ||
|
|
9eb5bbd8bd | ||
|
|
226e21b0fe | ||
|
|
b740bb3987 | ||
|
|
52793c14d9 | ||
|
|
e4a006cd3e | ||
|
|
9164dc11e2 | ||
|
|
f682193609 | ||
|
|
21f08a7488 | ||
|
|
057278b759 | ||
|
|
ad76e8a529 | ||
|
|
283ee1f6dc | ||
|
|
f5f94d9c08 | ||
|
|
9f25f736ed |
No files matched your search
@@ -0,0 +1,16 @@
|
||||
; http://editorconfig.org/
|
||||
|
||||
root = true
|
||||
|
||||
[*.{c,h}]
|
||||
charset = UTF-8
|
||||
end_of_line = LF
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
insert_final_newline = true
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
@@ -135,6 +135,7 @@ tests/*/*.sh
|
||||
*/tests/*/*.sh
|
||||
*/*/tests/*.diff
|
||||
*/*/tests/*.out
|
||||
*/*/tests/*.out.png
|
||||
*/*/tests/*.php
|
||||
*/*/tests/*.exp
|
||||
*/*/tests/*.log
|
||||
|
||||
@@ -181,8 +181,8 @@ STATUS: Working
|
||||
SINCE: 5.1
|
||||
-------------------------------------------------------------------------------
|
||||
EXTENSION: pdo_dblib
|
||||
PRIMARY MAINTAINER: Unknown
|
||||
MAINTENANCE: Odd fixes
|
||||
PRIMARY MAINTAINER: Adam Baratz <adambaratz@php.net>
|
||||
MAINTENANCE: Maintained
|
||||
STATUS: Working
|
||||
SINCE: 5.1
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
@@ -1,22 +1,149 @@
|
||||
PHP NEWS
|
||||
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
?? ??? 2016, PHP 5.6.26
|
||||
13 Oct 2016, PHP 5.6.27
|
||||
|
||||
- Streams:
|
||||
. Fixed bug #72853 (stream_set_blocking doesn't work). (Laruence)
|
||||
- Core:
|
||||
. Fixed bug #73025 (Heap Buffer Overflow in virtual_popen of
|
||||
zend_virtual_cwd.c). (cmb)
|
||||
. Fixed bug #73058 (crypt broken when salt is 'too' long). (Anatol)
|
||||
. Fixed bug #72703 (Out of bounds global memory read in BF_crypt triggered by
|
||||
password_verify). (Anatol)
|
||||
. Fixed bug #73189 (Memcpy negative size parameter php_resolve_path). (Stas)
|
||||
. Fixed bug #73147 (Use After Free in unserialize()). (Stas)
|
||||
|
||||
- BCmath:
|
||||
. Fixed bug #73190 (memcpy negative parameter _bc_new_num_ex). (Stas)
|
||||
|
||||
- DOM:
|
||||
. Fixed bug #73150 (missing NULL check in dom_document_save_html). (Stas)
|
||||
|
||||
- Ereg:
|
||||
. Fixed bug #73284 (heap overflow in php_ereg_replace function). (Stas)
|
||||
|
||||
- Filter:
|
||||
. Fixed bug #72972 (Bad filter for the flags FILTER_FLAG_NO_RES_RANGE and
|
||||
FILTER_FLAG_NO_PRIV_RANGE). (julien)
|
||||
. Fixed bug #67167 (Wrong return value from FILTER_VALIDATE_BOOLEAN,
|
||||
FILTER_NULL_ON_FAILURE). (levim, cmb)
|
||||
. Fixed bug #73054 (default option ignored when object passed to int filter).
|
||||
(cmb)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #67325 (imagetruecolortopalette: white is duplicated in palette).
|
||||
(cmb)
|
||||
. Fixed bug #50194 (imagettftext broken on transparent background w/o
|
||||
alphablending). (cmb)
|
||||
. Fixed bug #73003 (Integer Overflow in gdImageWebpCtx of gd_webp.c). (trylab,
|
||||
cmb)
|
||||
. Fixed bug #53504 (imagettfbbox gives incorrect values for bounding box).
|
||||
(Mark Plomer, cmb)
|
||||
. Fixed bug #73157 (imagegd2() ignores 3rd param if 4 are given). (cmb)
|
||||
. Fixed bug #73155 (imagegd2() writes wrong chunk sizes on boundaries). (cmb)
|
||||
. Fixed bug #73159 (imagegd2(): unrecognized formats may result in corrupted
|
||||
files). (cmb)
|
||||
. Fixed bug #73161 (imagecreatefromgd2() may leak memory). (cmb)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #73218 (add mitigation for ICU int overflow). (Stas)
|
||||
|
||||
- Imap:
|
||||
. Fixed bug #73208 (integer overflow in imap_8bit caused heap corruption).
|
||||
(Stas)
|
||||
|
||||
- Mbstring:
|
||||
. Fixed bug #72994 (mbc_to_code() out of bounds read). (Laruence, cmb)
|
||||
. Fixed bug #66964 (mb_convert_variables() cannot detect recursion). (Yasuo)
|
||||
. Fixed bug #72992 (mbstring.internal_encoding doesn't inherit default_charset).
|
||||
(Yasuo)
|
||||
. Fixed bug #73082 (string length overflow in mb_encode_* function). (Stas)
|
||||
|
||||
- PCRE:
|
||||
. Fixed bug #73174 (heap overflow in php_pcre_replace_impl). (Stas)
|
||||
|
||||
- Opcache:
|
||||
. Fixed bug #72590 (Opcache restart with kill_all_lockers does not work).
|
||||
(Keyur) (julien backport)
|
||||
|
||||
- OpenSSL:
|
||||
. Fixed bug #73072 (Invalid path SNI_server_certs causes segfault).
|
||||
(Jakub Zelenka)
|
||||
. Fixed bug #73275 (crash in openssl_encrypt function). (Stas)
|
||||
. Fixed bug #73276 (crash in openssl_random_pseudo_bytes function). (Stas)
|
||||
|
||||
- Session:
|
||||
. Fixed bug #68015 (Session does not report invalid uid for files save handler).
|
||||
(Yasuo)
|
||||
. Fixed bug #73100 (session_destroy null dereference in ps_files_path_create).
|
||||
(cmb)
|
||||
|
||||
- SimpleXML:
|
||||
. Fixed bug #73293 (NULL pointer dereference in SimpleXMLElement::asXML()).
|
||||
(Stas)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #73073 (CachingIterator null dereference when convert to string).
|
||||
(Stas)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #73240 (Write out of bounds at number_format). (Stas)
|
||||
. Fixed bug #73017 (memory corruption in wordwrap function). (Stas)
|
||||
|
||||
- Stream:
|
||||
. Fixed bug #73069 (readfile() mangles files larger than 2G). (Laruence)
|
||||
|
||||
- Zip:
|
||||
. Fixed bug #70752 (Depacking with wrong password leaves 0 length files).
|
||||
(cmb)
|
||||
|
||||
15 Sep 2016, PHP 5.6.26
|
||||
|
||||
- Core:
|
||||
. Fixed bug #72907 (null pointer deref, segfault in gc_remove_zval_from_buffer
|
||||
(zend_gc.c:260)). (Laruence)
|
||||
|
||||
- Dba:
|
||||
. Fixed bug #71514 (Bad dba_replace condition because of wrong API usage).
|
||||
(cmb)
|
||||
. Fixed bug #70825 (Cannot fetch multiple values with group in ini file).
|
||||
(cmb)
|
||||
|
||||
- EXIF:
|
||||
. Fixed bug #72926 (Uninitialized Thumbail Data Leads To Memory Leakage in
|
||||
exif_process_IFD_in_TIFF). (Stas)
|
||||
|
||||
- FTP:
|
||||
. Fixed bug #70195 (Cannot upload file using ftp_put to FTPES with
|
||||
require_ssl_reuse). (Benedict Singer)
|
||||
|
||||
- GD:
|
||||
. Fixed bug #66005 (imagecopy does not support 1bit transparency on truecolor
|
||||
images). (cmb)
|
||||
. Fixed bug #72913 (imagecopy() loses single-color transparency on palette
|
||||
images). (cmb)
|
||||
. Fixed bug #68716 (possible resource leaks in _php_image_convert()). (cmb)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug #73007 (add locale length check). (Stas)
|
||||
|
||||
- JSON:
|
||||
. Fixed bug #72787 (json_decode reads out of bounds). (Jakub Zelenka)
|
||||
|
||||
- mbstring:
|
||||
. Fixed bug #66797 (mb_substr only takes 32-bit signed integer). (cmb)
|
||||
. Fixed bug #72910 (Out of bounds heap read in mbc_to_code() / triggered by
|
||||
mb_ereg_match()). (Stas)
|
||||
|
||||
- MSSQL:
|
||||
. Fixed bug #72039 (Use of uninitialised value on mssql_guid_string). (Kalle)
|
||||
|
||||
- OCI8:
|
||||
. Fixed invalid handle error with Implicit Result Sets. (Chris Jones)
|
||||
- Mysqlnd:
|
||||
. Fixed bug #72293 (Heap overflow in mysqlnd related to BIT fields). (Stas)
|
||||
|
||||
- Phar:
|
||||
. Fixed bug #72928 (Out of bound when verify signature of zip phar in
|
||||
phar_parse_zipfile). (Stas)
|
||||
. Fixed bug #73035 (Out of bound when verify signature of tar phar in
|
||||
phar_parse_tarfile). (Stas)
|
||||
|
||||
- PDO:
|
||||
. Fixed bug #60665 (call to empty() on NULL result using PDO::FETCH_LAZY
|
||||
@@ -27,12 +154,32 @@ PHP NEWS
|
||||
specifying a sequence). (Pablo Santiago Sánchez, Matteo)
|
||||
. Fixed bug #72759 (Regression in pgo_pgsql). (Anatol)
|
||||
|
||||
- SPL:
|
||||
. Fixed bug #73029 (Missing type check when unserializing SplArray). (Stas)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #72823 (strtr out-of-bound access). (cmb)
|
||||
. Fixed bug #72278 (getimagesize returning FALSE on valid jpg). (cmb)
|
||||
. Fixed bug #65550 (get_browser() incorrectly parses entries with "+" sign).
|
||||
(cmb)
|
||||
. Fixed bug #71882 (Negative ftruncate() on php://memory exhausts memory).
|
||||
(cmb)
|
||||
. Fixed bug #73011 (integer overflow in fgets cause heap corruption). (Stas)
|
||||
. Fixed bug #73017 (memory corruption in wordwrap function). (Stas)
|
||||
. Fixed bug #73045 (integer overflow in fgetcsv caused heap corruption). (Stas)
|
||||
. Fixed bug #73052 (Memory Corruption in During Deserialized-object Destruction)
|
||||
(Stas)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug #72853 (stream_set_blocking doesn't work). (Laruence)
|
||||
|
||||
- Wddx:
|
||||
. Fixed bug #72860 (wddx_deserialize use-after-free). (Stas)
|
||||
. Fixed bug #73065 (Out-Of-Bounds Read in php_wddx_push_element). (Stas)
|
||||
|
||||
- XML:
|
||||
. Fixed bug #72085 (SEGV on unknown address zif_xml_parse). (cmb)
|
||||
. Fixed bug #72927 (integer overflow in xml_utf8_encode). (Stas)
|
||||
|
||||
- ZIP:
|
||||
. Fixed bug #68302 (impossible to compile php with zip support). (cmb)
|
||||
@@ -56,6 +203,8 @@ PHP NEWS
|
||||
. Fixed bug #72663 (Create an Unexpected Object and Don't Invoke
|
||||
__wakeup() in Deserialization). (Stas)
|
||||
. Fixed bug #72681 (PHP Session Data Injection Vulnerability). (Stas)
|
||||
. Fixed URL rewriter partially. It would not rewrite '//example.com/' URL
|
||||
unconditionally. Only requested host(HTTP_HOST) is rewritten. (Yasuo)
|
||||
|
||||
- Calendar:
|
||||
. Fixed bug #67976 (cal_days_month() fails for final month of the French
|
||||
@@ -116,6 +265,9 @@ PHP NEWS
|
||||
. Fixed bug #72710 (`mb_ereg` causes buffer overflow on regexp compile error).
|
||||
(ju1ius)
|
||||
|
||||
- OCI8:
|
||||
. Fixed invalid handle error with Implicit Result Sets. (Chris Jones)
|
||||
|
||||
- PCRE:
|
||||
. Fixed bug #72688 (preg_match missing group names in matches). (cmb)
|
||||
|
||||
@@ -137,7 +289,6 @@ PHP NEWS
|
||||
. Fixed bug #72848 (integer overflow in quoted_printable_encode). (Stas)
|
||||
. Fixed bug #72849 (integer overflow in urlencode). (Stas)
|
||||
. Fixed bug #72850 (integer overflow in php_uuencode). (Stas)
|
||||
. Fixed bug #72716 (initialize buffer before read). (Stas)
|
||||
|
||||
- Streams:
|
||||
. Fixed bug #41021 (Problems with the ftps wrapper). (vhuk)
|
||||
|
||||
@@ -616,6 +616,12 @@ TSRM_API int shmget(int key, int size, int flags)
|
||||
}
|
||||
} else {
|
||||
if (flags & IPC_EXCL) {
|
||||
if (shm_handle) {
|
||||
CloseHandle(shm_handle);
|
||||
}
|
||||
if (info_handle) {
|
||||
CloseHandle(info_handle);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -654,17 +660,27 @@ TSRM_API int shmget(int key, int size, int flags)
|
||||
TSRM_API void *shmat(int key, const void *shmaddr, int flags)
|
||||
{
|
||||
shm_pair *shm = shm_get(key, NULL);
|
||||
int err;
|
||||
|
||||
if (!shm->segment) {
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
shm->addr = MapViewOfFileEx(shm->segment, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
|
||||
|
||||
err = GetLastError();
|
||||
if (err) {
|
||||
/* Catch more errors */
|
||||
if (ERROR_NOT_ENOUGH_MEMORY == err) {
|
||||
_set_errno(ENOMEM);
|
||||
}
|
||||
return (void*)-1;
|
||||
}
|
||||
|
||||
shm->descriptor->shm_atime = time(NULL);
|
||||
shm->descriptor->shm_lpid = getpid();
|
||||
shm->descriptor->shm_nattch++;
|
||||
|
||||
shm->addr = MapViewOfFileEx(shm->segment, FILE_MAP_ALL_ACCESS, 0, 0, 0, NULL);
|
||||
|
||||
return shm->addr;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
Next free element may overflow in array literals
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$i = PHP_INT_MAX;
|
||||
$array = [$i => 42, new stdClass];
|
||||
var_dump($array);
|
||||
|
||||
const FOO = [PHP_INT_MAX => 42, "foo"];
|
||||
var_dump(FOO);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
|
||||
array(1) {
|
||||
[%d]=>
|
||||
int(42)
|
||||
}
|
||||
|
||||
Warning: Cannot add element to the array as the next element is already occupied in %s on line %d
|
||||
array(1) {
|
||||
[%d]=>
|
||||
int(42)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug #72907 (null pointer deref, segfault in gc_remove_zval_from_buffer (zend_gc.c:260))
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = 0;
|
||||
|
||||
($a->a = &$E) + ($b = $a->b->i -= 0);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Attempt to modify property of non-object in %sbug72907.php on line %d
|
||||
|
||||
Warning: Attempt to modify property of non-object in %sbug72907.php on line %d
|
||||
|
||||
Warning: Creating default object from empty value in %sbug72907.php on line %d
|
||||
|
||||
Notice: Undefined property: stdClass::$i in %sbug72907.php on line %d
|
||||
@@ -0,0 +1,15 @@
|
||||
--TEST--
|
||||
Constexpr arrays should be able to handle resource keys
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
const FOO = [STDIN => 42];
|
||||
var_dump(FOO);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Strict Standards: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
|
||||
array(1) {
|
||||
[%d]=>
|
||||
int(42)
|
||||
}
|
||||
@@ -1074,7 +1074,7 @@ static int zval_update_class_constant(zval **pp, int is_static, int offset TSRML
|
||||
*scope = old_scope;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
ce = ce->parent;
|
||||
} while (ce);
|
||||
|
||||
@@ -1279,9 +1279,14 @@ ZEND_API int add_assoc_double_ex(zval *arg, const char *key, uint key_len, doubl
|
||||
ZEND_API int add_assoc_string_ex(zval *arg, const char *key, uint key_len, char *str, int duplicate) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
ZVAL_STRINGL(tmp, str, _len, duplicate);
|
||||
|
||||
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), NULL);
|
||||
}
|
||||
@@ -1291,6 +1296,10 @@ ZEND_API int add_assoc_stringl_ex(zval *arg, const char *key, uint key_len, char
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1362,6 +1371,11 @@ ZEND_API int add_index_double(zval *arg, ulong index, double d) /* {{{ */
|
||||
ZEND_API int add_index_string(zval *arg, ulong index, const char *str, int duplicate) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
@@ -1374,6 +1388,10 @@ ZEND_API int add_index_stringl(zval *arg, ulong index, const char *str, uint len
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1457,6 +1475,9 @@ ZEND_API int add_next_index_stringl(zval *arg, const char *str, uint length, int
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1473,9 +1494,14 @@ ZEND_API int add_next_index_zval(zval *arg, zval *value) /* {{{ */
|
||||
ZEND_API int add_get_assoc_string_ex(zval *arg, const char *key, uint key_len, const char *str, void **dest, int duplicate) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
ZVAL_STRINGL(tmp, str, _len, duplicate);
|
||||
|
||||
return zend_symtable_update(Z_ARRVAL_P(arg), key, key_len, (void *) &tmp, sizeof(zval *), dest);
|
||||
}
|
||||
@@ -1485,6 +1511,10 @@ ZEND_API int add_get_assoc_stringl_ex(zval *arg, const char *key, uint key_len,
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1664,9 +1694,14 @@ ZEND_API int add_property_string_ex(zval *arg, const char *key, uint key_len, co
|
||||
{
|
||||
zval *tmp;
|
||||
zval *z_key;
|
||||
size_t _len = strlen(str);
|
||||
|
||||
if (UNEXPECTED(_len > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRING(tmp, str, duplicate);
|
||||
ZVAL_STRINGL(tmp, str, _len, duplicate);
|
||||
|
||||
MAKE_STD_ZVAL(z_key);
|
||||
ZVAL_STRINGL(z_key, key, key_len-1, 1);
|
||||
@@ -1683,6 +1718,10 @@ ZEND_API int add_property_stringl_ex(zval *arg, const char *key, uint key_len, c
|
||||
zval *tmp;
|
||||
zval *z_key;
|
||||
|
||||
if (UNEXPECTED(length > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
|
||||
MAKE_STD_ZVAL(tmp);
|
||||
ZVAL_STRINGL(tmp, str, length, duplicate);
|
||||
|
||||
@@ -1766,6 +1805,12 @@ ZEND_API int zend_startup_module_ex(zend_module_entry *module TSRMLS_DC) /* {{{
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_startup_module_int(zend_module_entry *module TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
return (zend_startup_module_ex(module TSRMLS_CC) == SUCCESS) ? ZEND_HASH_APPLY_KEEP : ZEND_HASH_APPLY_REMOVE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void zend_sort_modules(void *base, size_t count, size_t siz, compare_func_t compare TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
Bucket **b1 = base;
|
||||
@@ -1836,7 +1881,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */
|
||||
module_post_deactivate_handlers = module_request_shutdown_handlers + shutdown_count + 1;
|
||||
module_post_deactivate_handlers[post_deactivate_count] = NULL;
|
||||
startup_count = 0;
|
||||
|
||||
|
||||
for (zend_hash_internal_pointer_reset_ex(&module_registry, &pos);
|
||||
zend_hash_get_current_data_ex(&module_registry, (void *) &module, &pos) == SUCCESS;
|
||||
zend_hash_move_forward_ex(&module_registry, &pos)) {
|
||||
@@ -1882,7 +1927,7 @@ ZEND_API void zend_collect_module_handlers(TSRMLS_D) /* {{{ */
|
||||
ZEND_API int zend_startup_modules(TSRMLS_D) /* {{{ */
|
||||
{
|
||||
zend_hash_sort(&module_registry, zend_sort_modules, NULL, 0 TSRMLS_CC);
|
||||
zend_hash_apply(&module_registry, (apply_func_t)zend_startup_module_ex TSRMLS_CC);
|
||||
zend_hash_apply(&module_registry, (apply_func_t)zend_startup_module_int TSRMLS_CC);
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
@@ -2083,7 +2128,7 @@ ZEND_API int zend_register_functions(zend_class_entry *scope, const zend_functio
|
||||
}
|
||||
if (ptr->arg_info) {
|
||||
zend_internal_function_info *info = (zend_internal_function_info*)ptr->arg_info;
|
||||
|
||||
|
||||
internal_function->arg_info = (zend_arg_info*)ptr->arg_info+1;
|
||||
internal_function->num_args = ptr->num_args;
|
||||
/* Currently you cannot denote that the function can accept less arguments than num_args */
|
||||
@@ -2701,7 +2746,7 @@ static int zend_is_callable_check_class(const char *name, int name_len, zend_fca
|
||||
}
|
||||
ret = 1;
|
||||
}
|
||||
} else if (name_len == sizeof("parent") - 1 &&
|
||||
} else if (name_len == sizeof("parent") - 1 &&
|
||||
!memcmp(lcname, "parent", sizeof("parent") - 1)) {
|
||||
if (!EG(scope)) {
|
||||
if (error) *error = estrdup("cannot access parent:: when no class scope is active");
|
||||
@@ -3030,7 +3075,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
if (error) {
|
||||
*error = NULL;
|
||||
}
|
||||
|
||||
|
||||
fcc->initialized = 0;
|
||||
fcc->calling_scope = NULL;
|
||||
fcc->called_scope = NULL;
|
||||
@@ -3042,7 +3087,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
object_ptr = NULL;
|
||||
}
|
||||
if (object_ptr &&
|
||||
(!EG(objects_store).object_buckets ||
|
||||
(!EG(objects_store).object_buckets ||
|
||||
!EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(object_ptr)].valid)) {
|
||||
return 0;
|
||||
}
|
||||
@@ -3123,7 +3168,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!EG(objects_store).object_buckets ||
|
||||
if (!EG(objects_store).object_buckets ||
|
||||
!EG(objects_store).object_buckets[Z_OBJ_HANDLE_PP(obj)].valid) {
|
||||
return 0;
|
||||
}
|
||||
@@ -3192,7 +3237,7 @@ ZEND_API zend_bool zend_is_callable_ex(zval *callable, zval *object_ptr, uint ch
|
||||
*callable_name = emalloc(*callable_name_len + 1);
|
||||
memcpy(*callable_name, ce->name, ce->name_length);
|
||||
memcpy((*callable_name) + ce->name_length, "::__invoke", sizeof("::__invoke"));
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/* break missing intentionally */
|
||||
@@ -3731,6 +3776,30 @@ ZEND_API void zend_update_property(zend_class_entry *scope, zval *object, const
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zval *property;
|
||||
zend_class_entry *old_scope = EG(scope);
|
||||
|
||||
EG(scope) = scope;
|
||||
|
||||
if (!Z_OBJ_HT_P(object)->unset_property) {
|
||||
const char *class_name;
|
||||
zend_uint class_name_len;
|
||||
|
||||
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
|
||||
|
||||
zend_error(E_CORE_ERROR, "Property %s of class %s cannot be unset", name, class_name);
|
||||
}
|
||||
MAKE_STD_ZVAL(property);
|
||||
ZVAL_STRINGL(property, name, name_length, 1);
|
||||
Z_OBJ_HT_P(object)->unset_property(object, property, 0 TSRMLS_CC);
|
||||
zval_ptr_dtor(&property);
|
||||
|
||||
EG(scope) = old_scope;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
ZEND_API void zend_update_property_null(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zval *tmp;
|
||||
|
||||
@@ -330,6 +330,7 @@ ZEND_API void zend_update_property_long(zend_class_entry *scope, zval *object, c
|
||||
ZEND_API void zend_update_property_double(zend_class_entry *scope, zval *object, const char *name, int name_length, double value TSRMLS_DC);
|
||||
ZEND_API void zend_update_property_string(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value TSRMLS_DC);
|
||||
ZEND_API void zend_update_property_stringl(zend_class_entry *scope, zval *object, const char *name, int name_length, const char *value, int value_length TSRMLS_DC);
|
||||
ZEND_API void zend_unset_property(zend_class_entry *scope, zval *object, const char *name, int name_length TSRMLS_DC);
|
||||
|
||||
ZEND_API int zend_update_static_property(zend_class_entry *scope, const char *name, int name_length, zval *value TSRMLS_DC);
|
||||
ZEND_API int zend_update_static_property_null(zend_class_entry *scope, const char *name, int name_length TSRMLS_DC);
|
||||
@@ -654,6 +655,20 @@ END_EXTERN_C()
|
||||
} while (0)
|
||||
#define RETURN_ZVAL_FAST(z) { RETVAL_ZVAL_FAST(z); return; }
|
||||
|
||||
/* Check that returned string length fits int */
|
||||
#define RETVAL_STRINGL_CHECK(s, len, dup) do { \
|
||||
size_t __len = (len); \
|
||||
if (UNEXPECTED(__len > INT_MAX)) { \
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "String too long, max is %d", INT_MAX); \
|
||||
if(!(dup)) { \
|
||||
efree((s)); \
|
||||
} \
|
||||
RETURN_FALSE; \
|
||||
} \
|
||||
RETVAL_STRINGL((s), (int)__len, (dup)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define SET_VAR_STRING(n, v) { \
|
||||
{ \
|
||||
zval *var; \
|
||||
|
||||
@@ -2578,6 +2578,15 @@ static inline size_t safe_address(size_t nmemb, size_t size, size_t offset)
|
||||
#endif
|
||||
|
||||
|
||||
ZEND_API void *_safe_emalloc_string(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
size_t str_size = safe_address(nmemb, size, offset);
|
||||
if (UNEXPECTED(str_size > INT_MAX)) {
|
||||
zend_error_noreturn(E_ERROR, "String allocation overflow, max size is %d", INT_MAX);
|
||||
}
|
||||
return emalloc_rel(str_size);
|
||||
}
|
||||
|
||||
ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
|
||||
{
|
||||
return emalloc_rel(safe_address(nmemb, size, offset));
|
||||
@@ -2726,9 +2735,9 @@ static void alloc_globals_ctor(zend_alloc_globals *alloc_globals TSRMLS_DC)
|
||||
alloc_globals->mm_heap = malloc(sizeof(struct _zend_mm_heap));
|
||||
memset(alloc_globals->mm_heap, 0, sizeof(struct _zend_mm_heap));
|
||||
alloc_globals->mm_heap->use_zend_alloc = 0;
|
||||
alloc_globals->mm_heap->_malloc = malloc;
|
||||
alloc_globals->mm_heap->_malloc = __zend_malloc;
|
||||
alloc_globals->mm_heap->_free = free;
|
||||
alloc_globals->mm_heap->_realloc = realloc;
|
||||
alloc_globals->mm_heap->_realloc = __zend_realloc;
|
||||
} else {
|
||||
alloc_globals->mm_heap = zend_mm_startup();
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
| Copyright (c) 1998-2016 Zend Technologies Ltd. (http://www.zend.com) |
|
||||
+----------------------------------------------------------------------+
|
||||
| This source file is subject to version 2.00 of the Zend license, |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
| available through the world-wide-web at the following url: |
|
||||
| http://www.zend.com/license/2_00.txt. |
|
||||
| If you did not receive a copy of the Zend license and are unable to |
|
||||
@@ -56,6 +56,7 @@ ZEND_API char *zend_strndup(const char *s, unsigned int length) ZEND_ATTRIBUTE_M
|
||||
|
||||
ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE(1);
|
||||
ZEND_API void *_safe_emalloc(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
|
||||
ZEND_API void *_safe_emalloc_string(size_t nmemb, size_t size, size_t offset ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC;
|
||||
ZEND_API void *_safe_malloc(size_t nmemb, size_t size, size_t offset) ZEND_ATTRIBUTE_MALLOC;
|
||||
ZEND_API void _efree(void *ptr ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
|
||||
ZEND_API void *_ecalloc(size_t nmemb, size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) ZEND_ATTRIBUTE_MALLOC ZEND_ATTRIBUTE_ALLOC_SIZE2(1,2);
|
||||
@@ -69,6 +70,7 @@ ZEND_API size_t _zend_mem_block_size(void *ptr TSRMLS_DC ZEND_FILE_LINE_DC ZEND_
|
||||
/* Standard wrapper macros */
|
||||
#define emalloc(size) _emalloc((size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define safe_emalloc(nmemb, size, offset) _safe_emalloc((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define safe_emalloc_string(nmemb, size, offset) _safe_emalloc_string((nmemb), (size), (offset) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define efree(ptr) _efree((ptr) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define ecalloc(nmemb, size) _ecalloc((nmemb), (size) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
#define erealloc(ptr, size) _erealloc((ptr), (size), 0 ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
|
||||
|
||||
@@ -5929,7 +5929,7 @@ void zend_do_add_array_element(znode *result, const znode *expr, const znode *of
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr) /* {{{ */
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, zval *expr) /* {{{ */
|
||||
{
|
||||
if (offset) {
|
||||
switch (Z_TYPE_P(offset)) {
|
||||
@@ -5940,6 +5940,9 @@ void zend_do_add_static_array_element(zval *result, zval *offset, const zval *ex
|
||||
case IS_NULL:
|
||||
zend_symtable_update(Z_ARRVAL_P(result), "", 1, &expr, sizeof(zval *), NULL);
|
||||
break;
|
||||
case IS_RESOURCE:
|
||||
zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(offset), Z_LVAL_P(offset));
|
||||
/* break missing intentionally */
|
||||
case IS_LONG:
|
||||
case IS_BOOL:
|
||||
zend_hash_index_update(Z_ARRVAL_P(result), Z_LVAL_P(offset), &expr, sizeof(zval *), NULL);
|
||||
@@ -5952,7 +5955,10 @@ void zend_do_add_static_array_element(zval *result, zval *offset, const zval *ex
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL_P(result), &expr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -598,7 +598,7 @@ void zend_do_shell_exec(znode *result, const znode *cmd TSRMLS_DC);
|
||||
|
||||
void zend_do_init_array(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
|
||||
void zend_do_add_array_element(znode *result, const znode *expr, const znode *offset, zend_bool is_ref TSRMLS_DC);
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, const zval *expr);
|
||||
void zend_do_add_static_array_element(zval *result, zval *offset, zval *expr);
|
||||
void zend_do_list_init(TSRMLS_D);
|
||||
void zend_do_list_end(znode *result, znode *expr TSRMLS_DC);
|
||||
void zend_do_add_list_element(const znode *element TSRMLS_DC);
|
||||
|
||||
@@ -229,13 +229,9 @@ ZEND_METHOD(exception, __construct)
|
||||
/* {{{ proto Exception::__wakeup()
|
||||
Exception unserialize checks */
|
||||
#define CHECK_EXC_TYPE(name, type) \
|
||||
value = zend_read_property(default_exception_ce, object, name, sizeof(name)-1, 0 TSRMLS_CC); \
|
||||
value = zend_read_property(default_exception_ce, object, name, sizeof(name)-1, 1 TSRMLS_CC); \
|
||||
if (value && Z_TYPE_P(value) != IS_NULL && Z_TYPE_P(value) != type) { \
|
||||
zval *tmp; \
|
||||
MAKE_STD_ZVAL(tmp); \
|
||||
ZVAL_STRINGL(tmp, name, sizeof(name)-1, 1); \
|
||||
Z_OBJ_HANDLER_P(object, unset_property)(object, tmp, 0 TSRMLS_CC); \
|
||||
zval_ptr_dtor(&tmp); \
|
||||
zend_unset_property(default_exception_ce, object, name, sizeof(name)-1 TSRMLS_CC); \
|
||||
}
|
||||
|
||||
ZEND_METHOD(exception, __wakeup)
|
||||
@@ -248,7 +244,12 @@ ZEND_METHOD(exception, __wakeup)
|
||||
CHECK_EXC_TYPE("file", IS_STRING);
|
||||
CHECK_EXC_TYPE("line", IS_LONG);
|
||||
CHECK_EXC_TYPE("trace", IS_ARRAY);
|
||||
CHECK_EXC_TYPE("previous", IS_OBJECT);
|
||||
value = zend_read_property(default_exception_ce, object, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
|
||||
if (value && Z_TYPE_P(value) != IS_NULL && (Z_TYPE_P(value) != IS_OBJECT ||
|
||||
!instanceof_function(Z_OBJCE_P(value), default_exception_ce TSRMLS_CC) ||
|
||||
value == object)) {
|
||||
zend_unset_property(default_exception_ce, object, "previous", sizeof("previous")-1 TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -727,7 +728,11 @@ ZEND_METHOD(exception, __toString)
|
||||
zval_dtor(&file);
|
||||
zval_dtor(&line);
|
||||
|
||||
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 0 TSRMLS_CC);
|
||||
Z_OBJPROP_P(exception)->nApplyCount++;
|
||||
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
|
||||
if (exception && Z_TYPE_P(exception) == IS_OBJECT && Z_OBJPROP_P(exception)->nApplyCount > 0) {
|
||||
exception = NULL;
|
||||
}
|
||||
|
||||
if (trace) {
|
||||
zval_ptr_dtor(&trace);
|
||||
@@ -736,6 +741,17 @@ ZEND_METHOD(exception, __toString)
|
||||
}
|
||||
zval_dtor(&fname);
|
||||
|
||||
/* Reset apply counts */
|
||||
exception = getThis();
|
||||
while (exception && Z_TYPE_P(exception) == IS_OBJECT && instanceof_function(Z_OBJCE_P(exception), default_exception_ce TSRMLS_CC)) {
|
||||
if(Z_OBJPROP_P(exception)->nApplyCount) {
|
||||
Z_OBJPROP_P(exception)->nApplyCount--;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
exception = zend_read_property(default_exception_ce, exception, "previous", sizeof("previous")-1, 1 TSRMLS_CC);
|
||||
}
|
||||
|
||||
/* We store the result in the private property string so we can access
|
||||
* the result in uncaught exception handlers without memleaks. */
|
||||
zend_update_property_string(default_exception_ce, getThis(), "string", sizeof("string")-1, str TSRMLS_CC);
|
||||
|
||||
@@ -522,9 +522,7 @@ static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **va
|
||||
zval *variable_ptr = *variable_ptr_ptr;
|
||||
zval *value_ptr = *value_ptr_ptr;
|
||||
|
||||
if (variable_ptr == &EG(error_zval) || value_ptr == &EG(error_zval)) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else if (variable_ptr != value_ptr) {
|
||||
if (variable_ptr != value_ptr) {
|
||||
if (!PZVAL_IS_REF(value_ptr)) {
|
||||
/* break it away */
|
||||
Z_DELREF_P(value_ptr);
|
||||
|
||||
@@ -215,7 +215,7 @@ ZEND_API void zend_objects_store_del_ref_by_handle_ex(zend_object_handle handle,
|
||||
} zend_end_try();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* re-read the object from the object store as the store might have been reallocated in the dtor */
|
||||
obj = &EG(objects_store).object_buckets[handle].bucket.obj;
|
||||
|
||||
@@ -306,8 +306,8 @@ ZEND_API void zend_object_store_ctor_failed(zval *zobject TSRMLS_DC)
|
||||
{
|
||||
zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
|
||||
zend_object_store_bucket *obj_bucket = &EG(objects_store).object_buckets[handle];
|
||||
|
||||
obj_bucket->bucket.obj.handlers = Z_OBJ_HT_P(zobject);;
|
||||
|
||||
obj_bucket->bucket.obj.handlers = Z_OBJ_HT_P(zobject);
|
||||
obj_bucket->destructor_called = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -1896,7 +1896,7 @@ CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /*
|
||||
#else /* Unix */
|
||||
CWD_API FILE *virtual_popen(const char *command, const char *type TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int command_length;
|
||||
size_t command_length;
|
||||
int dir_length, extra = 0;
|
||||
char *command_line;
|
||||
char *ptr, *dir;
|
||||
|
||||
@@ -1817,11 +1817,14 @@ ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
|
||||
if ((OP2_TYPE == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(OP1_TYPE == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (OP2_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((OP2_TYPE == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(OP1_TYPE == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (OP2_TYPE == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -3876,7 +3879,10 @@ ZEND_VM_C_LABEL(num_index):
|
||||
}
|
||||
FREE_OP2();
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) && opline->extended_value) {
|
||||
FREE_OP1_VAR_PTR();
|
||||
|
||||
@@ -4119,7 +4119,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -5030,7 +5033,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -5894,7 +5900,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -6614,7 +6623,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -7547,7 +7559,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CONST == IS_VAR || IS_CONST == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -9447,7 +9462,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -10314,7 +10332,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -11180,7 +11201,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -11775,7 +11799,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -12624,7 +12651,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -16107,7 +16137,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -18387,7 +18420,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -20408,11 +20444,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_VAR_HANDLER(ZEND_OPCODE_HANDL
|
||||
if ((IS_VAR == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_VAR == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -20722,7 +20761,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -22162,7 +22204,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -23903,11 +23948,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_VAR_CV_HANDLER(ZEND_OPCODE_HANDLE
|
||||
if ((IS_CV == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_CV == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_VAR == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -24214,7 +24262,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_VAR == IS_VAR || IS_VAR == IS_CV) && opline->extended_value) {
|
||||
if (free_op1.var) {zval_ptr_dtor_nogc(&free_op1.var);};
|
||||
@@ -33568,7 +33619,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -35711,7 +35765,10 @@ num_index:
|
||||
}
|
||||
zval_dtor(free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -37721,11 +37778,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_VAR_HANDLER(ZEND_OPCODE_HANDLE
|
||||
if ((IS_VAR == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_VAR == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_VAR == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -37908,7 +37968,10 @@ num_index:
|
||||
}
|
||||
zval_ptr_dtor_nogc(&free_op2.var);
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -39216,7 +39279,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
@@ -40929,11 +40995,14 @@ static int ZEND_FASTCALL ZEND_ASSIGN_REF_SPEC_CV_CV_HANDLER(ZEND_OPCODE_HANDLER
|
||||
if ((IS_CV == IS_VAR && UNEXPECTED(value_ptr_ptr == NULL)) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(variable_ptr_ptr == NULL))) {
|
||||
zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects");
|
||||
}
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
} else if ((IS_CV == IS_VAR && UNEXPECTED(*value_ptr_ptr == &EG(error_zval))) ||
|
||||
(IS_CV == IS_VAR && UNEXPECTED(*variable_ptr_ptr == &EG(error_zval)))) {
|
||||
variable_ptr_ptr = &EG(uninitialized_zval_ptr);
|
||||
} else {
|
||||
zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC);
|
||||
if (IS_CV == IS_VAR && opline->extended_value == ZEND_RETURNS_NEW) {
|
||||
Z_DELREF_PP(variable_ptr_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (RETURN_VALUE_USED(opline)) {
|
||||
@@ -41113,7 +41182,10 @@ num_index:
|
||||
}
|
||||
|
||||
} else {
|
||||
zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL);
|
||||
if (zend_hash_next_index_insert(Z_ARRVAL(EX_T(opline->result.var).tmp_var), &expr_ptr, sizeof(zval *), NULL) == FAILURE) {
|
||||
zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied");
|
||||
zval_ptr_dtor(&expr_ptr);
|
||||
}
|
||||
}
|
||||
if ((IS_CV == IS_VAR || IS_CV == IS_CV) && opline->extended_value) {
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
|
||||
|
||||
PHP_MAJOR_VERSION=5
|
||||
PHP_MINOR_VERSION=6
|
||||
PHP_RELEASE_VERSION=26
|
||||
PHP_EXTRA_VERSION="-dev"
|
||||
PHP_RELEASE_VERSION=27
|
||||
PHP_EXTRA_VERSION=""
|
||||
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
|
||||
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
|
||||
|
||||
|
||||
@@ -49,7 +49,10 @@ _bc_new_num_ex (length, scale, persistent)
|
||||
int length, scale, persistent;
|
||||
{
|
||||
bc_num temp;
|
||||
|
||||
/* PHP Change: add length check */
|
||||
if ((size_t)length+(size_t)scale > INT_MAX) {
|
||||
zend_error(E_ERROR, "Result too long, max is %d", INT_MAX);
|
||||
}
|
||||
/* PHP Change: malloc() -> pemalloc(), removed free_list code */
|
||||
temp = (bc_num) safe_pemalloc (1, sizeof(bc_struct)+length, scale, persistent);
|
||||
#if 0
|
||||
|
||||
@@ -41,6 +41,5 @@
|
||||
|
||||
void bc_out_of_memory (void)
|
||||
{
|
||||
(void) fprintf (stderr, "bcmath: out of memory!\n");
|
||||
exit (1);
|
||||
zend_error(E_ERROR, "bcmath: out of memory!");
|
||||
}
|
||||
@@ -137,7 +137,10 @@ ZEND_METHOD(CURLFile, setPostFilename)
|
||||
Unserialization handler */
|
||||
ZEND_METHOD(CURLFile, __wakeup)
|
||||
{
|
||||
zend_update_property_string(curl_CURLFile_class, getThis(), "name", sizeof("name")-1, "" TSRMLS_CC);
|
||||
zval *_this = getThis();
|
||||
|
||||
zend_unset_property(curl_CURLFile_class, _this, "name", sizeof("name")-1 TSRMLS_CC);
|
||||
zend_update_property_string(curl_CURLFile_class, _this, "name", sizeof("name")-1, "" TSRMLS_CC);
|
||||
zend_throw_exception(NULL, "Unserialization of CURLFile instances is not allowed", 0 TSRMLS_CC);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -1851,8 +1851,9 @@ static void create_certinfo(struct curl_certinfo *ci, zval *listcode TSRMLS_DC)
|
||||
int len;
|
||||
char s[64];
|
||||
char *tmp;
|
||||
strncpy(s, slist->data, 64);
|
||||
tmp = memchr(s, ':', 64);
|
||||
strncpy(s, slist->data, sizeof(s));
|
||||
s[sizeof(s)-1] = '\0';
|
||||
tmp = memchr(s, ':', sizeof(s));
|
||||
if(tmp) {
|
||||
*tmp = '\0';
|
||||
len = strlen(s);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #73147: Use After Free in PHP7 unserialize()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("curl")) {
|
||||
exit("skip curl extension not loaded");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$poc = 'a:1:{i:0;O:8:"CURLFile":1:{s:4:"name";R:1;}}';
|
||||
try {
|
||||
var_dump(unserialize($poc));
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Unserialization of CURLFile instances is not allowed
|
||||
@@ -250,6 +250,7 @@ val_type inifile_fetch(inifile *dba, const key_type *key, int skip TSRMLS_DC) {
|
||||
if (skip == -1 && dba->next.key.group && dba->next.key.name && !inifile_key_cmp(&dba->next.key, key TSRMLS_CC)) {
|
||||
/* we got position already from last fetch */
|
||||
php_stream_seek(dba->fp, dba->next.pos, SEEK_SET);
|
||||
ln.key.group = estrdup(dba->next.key.group);
|
||||
} else {
|
||||
/* specific instance or not same key -> restart search */
|
||||
/* the slow way: restart and seacrch */
|
||||
@@ -402,7 +403,7 @@ static int inifile_copy_to(inifile *dba, size_t pos_start, size_t pos_end, inifi
|
||||
return FAILURE;
|
||||
}
|
||||
php_stream_seek(dba->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp, pos_end - pos_start, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy group [%zu - %zu] to temporary stream", pos_start, pos_end);
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -427,7 +428,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML
|
||||
pos_curr = php_stream_tell(from->fp);
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
@@ -446,7 +447,7 @@ static int inifile_filter(inifile *dba, inifile *from, const key_type *key TSRML
|
||||
}
|
||||
if (pos_start != pos_next) {
|
||||
php_stream_seek(from->fp, pos_start, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(from->fp, dba->fp, pos_next - pos_start, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy [%zu - %zu] from temporary stream", pos_next, pos_start);
|
||||
ret = FAILURE;
|
||||
}
|
||||
@@ -497,7 +498,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (pos_grp_next != (size_t)php_stream_tell(dba->fp)) {
|
||||
php_stream_seek(dba->fp, pos_grp_next, SEEK_SET);
|
||||
if (!php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(dba->fp, fp_tmp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not copy remainder to temporary stream");
|
||||
ret = FAILURE;
|
||||
}
|
||||
@@ -538,7 +539,7 @@ static int inifile_delete_replace_append(inifile *dba, const key_type *key, cons
|
||||
if (fp_tmp && php_stream_tell(fp_tmp)) {
|
||||
php_stream_seek(fp_tmp, 0, SEEK_SET);
|
||||
php_stream_seek(dba->fp, 0, SEEK_END);
|
||||
if (!php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
if (SUCCESS != php_stream_copy_to_stream_ex(fp_tmp, dba->fp, PHP_STREAM_COPY_ALL, NULL)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Could not copy from temporary stream - ini file truncated");
|
||||
ret = FAILURE;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
--TEST--
|
||||
Bug #70825 (Cannot fetch multiple values with group in ini file)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dba')) die('skip dba extension not available');
|
||||
if (!in_array('inifile', dba_handlers())) die('skip inifile handler not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert('foo', 23, $db);
|
||||
dba_insert('foo', 42, $db);
|
||||
dba_insert('foo', 1337, $db);
|
||||
var_dump(dba_fetch('foo', -1, $db));
|
||||
var_dump(dba_fetch('foo', -1, $db));
|
||||
var_dump(dba_fetch('foo', -1, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert(['foo', 'bar'], 23, $db);
|
||||
dba_insert(['foo', 'bar'], 42, $db);
|
||||
dba_insert(['foo', 'bar'], 1337, $db);
|
||||
var_dump(dba_fetch(['foo', 'bar'], -1, $db));
|
||||
var_dump(dba_fetch(['foo', 'bar'], -1, $db));
|
||||
var_dump(dba_fetch(['foo', 'bar'], -1, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert('[foo]bar', 23, $db);
|
||||
dba_insert('[foo]bar', 42, $db);
|
||||
dba_insert('[foo]bar', 1337, $db);
|
||||
var_dump(dba_fetch('[foo]bar', -1, $db));
|
||||
var_dump(dba_fetch('[foo]bar', -1, $db));
|
||||
var_dump(dba_fetch('[foo]bar', -1, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
|
||||
$db = dba_open($filename, 'n', 'inifile');
|
||||
dba_insert('[foo]bar', 23, $db);
|
||||
dba_insert('[foo]bar', 42, $db);
|
||||
dba_insert('[foo]bar', 1337, $db);
|
||||
var_dump(dba_fetch('[foo]bar', 0, $db));
|
||||
var_dump(dba_fetch('[foo]bar', 1, $db));
|
||||
var_dump(dba_fetch('[foo]bar', 2, $db));
|
||||
dba_close($db);
|
||||
unlink($filename);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
string(2) "23"
|
||||
string(2) "42"
|
||||
string(4) "1337"
|
||||
==DONE==
|
||||
--CLEAN--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug70825.ini';
|
||||
unlink($filename);
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #71514 (Bad dba_replace condition because of wrong API usage)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('dba')) die('skip dba extension not available');
|
||||
if (!in_array('inifile', dba_handlers())) die('skip inifile handler not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug71514.ini';
|
||||
|
||||
$db = dba_open($filename, 'c', 'inifile');
|
||||
|
||||
dba_insert('foo', 'value1', $db);
|
||||
dba_replace('foo', 'value2', $db);
|
||||
var_dump(dba_fetch('foo', $db));
|
||||
|
||||
dba_close($db);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(6) "value2"
|
||||
==DONE==
|
||||
--CLEAN--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug71514.ini';
|
||||
unlink($filename);
|
||||
?>
|
||||
@@ -1792,7 +1792,7 @@ PHP_FUNCTION(dom_document_savexml)
|
||||
if (options & LIBXML_SAVE_NOEMPTYTAG) {
|
||||
xmlSaveNoEmptyTags = saveempty;
|
||||
}
|
||||
if (!size) {
|
||||
if (!size || !mem) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
RETVAL_STRINGL(mem, size, 1);
|
||||
@@ -2327,7 +2327,7 @@ PHP_FUNCTION(dom_document_save_html)
|
||||
#else
|
||||
htmlDocDumpMemory(docp, &mem, &size);
|
||||
#endif
|
||||
if (!size) {
|
||||
if (!size || !mem) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_STRINGL((const char*) mem, size, 1);
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
+----------------------------------------------------------------------+
|
||||
| Authors: Rasmus Lerdorf <rasmus@php.net> |
|
||||
| Jim Winstead <jimw@php.net> |
|
||||
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
|
||||
| Jaakko Hyvätti <jaakko@hyvatti.iki.fi> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
/* $Id$ */
|
||||
@@ -29,7 +29,7 @@
|
||||
/* {{{ arginfo */
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_ereg, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(1, registers) /* ARRAY_INFO(1, registers, 1) */
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
@@ -41,8 +41,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_split, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, pattern)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_ARG_INFO(0, string)
|
||||
ZEND_ARG_INFO(0, limit)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_sql_regcase, 0)
|
||||
@@ -204,7 +204,7 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags TSRMLS_DC
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void _free_ereg_cache(reg_cache *rc)
|
||||
static void _free_ereg_cache(reg_cache *rc)
|
||||
{
|
||||
regfree(&rc->preg);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
if (icase) {
|
||||
copts |= REG_ICASE;
|
||||
}
|
||||
|
||||
|
||||
if (argc == 2) {
|
||||
copts |= REG_NOSUB;
|
||||
}
|
||||
@@ -337,7 +337,7 @@ static void php_ereg(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
|
||||
/* allocate storage for (sub-)expression-matches */
|
||||
subs = (regmatch_t *)ecalloc(sizeof(regmatch_t),re.re_nsub+1);
|
||||
|
||||
|
||||
/* actually execute the regular expression */
|
||||
err = regexec(&re, string, re.re_nsub+1, subs, 0);
|
||||
if (err && err != REG_NOMATCH) {
|
||||
@@ -409,8 +409,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
*nbuf, /* nbuf is used when we grow the buffer */
|
||||
*walkbuf; /* used to walk buf when replacing backrefs */
|
||||
const char *walk; /* used to walk replacement string for backrefs */
|
||||
int buf_len;
|
||||
int pos, tmp, string_len, new_l;
|
||||
size_t buf_len, new_l;
|
||||
int pos, tmp, string_len;
|
||||
int err, copts = 0;
|
||||
|
||||
string_len = strlen(string);
|
||||
@@ -434,8 +434,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
|
||||
/* start with a buffer that is twice the size of the stringo
|
||||
we're doing replacements in */
|
||||
buf = safe_emalloc(string_len, 2, 1);
|
||||
buf_len = 2 * string_len + 1;
|
||||
buf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
|
||||
err = pos = 0;
|
||||
buf[0] = '\0';
|
||||
@@ -472,8 +472,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
}
|
||||
}
|
||||
if (new_l + 1 > buf_len) {
|
||||
nbuf = safe_emalloc(new_l + 1, 2, buf_len);
|
||||
buf_len = 1 + buf_len + 2 * new_l;
|
||||
nbuf = emalloc(buf_len);
|
||||
strncpy(nbuf, buf, buf_len - 1);
|
||||
nbuf[buf_len - 1] = '\0';
|
||||
efree(buf);
|
||||
@@ -491,7 +491,7 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1
|
||||
/* this next case shouldn't happen. it does. */
|
||||
&& subs[walk[1] - '0'].rm_so <= subs[walk[1] - '0'].rm_eo) {
|
||||
|
||||
|
||||
tmp = subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
|
||||
memcpy (walkbuf, &string[pos + subs[walk[1] - '0'].rm_so], tmp);
|
||||
walkbuf += tmp;
|
||||
@@ -510,8 +510,8 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
}
|
||||
new_l = strlen (buf) + 1;
|
||||
if (new_l + 1 > buf_len) {
|
||||
nbuf = safe_emalloc(new_l + 1, 2, buf_len);
|
||||
buf_len = 1 + buf_len + 2 * new_l;
|
||||
nbuf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
strncpy(nbuf, buf, buf_len-1);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
@@ -526,7 +526,7 @@ PHP_EREG_API char *php_ereg_replace(const char *pattern, const char *replace, co
|
||||
new_l = strlen(buf) + strlen(&string[pos]);
|
||||
if (new_l + 1 > buf_len) {
|
||||
buf_len = new_l + 1; /* now we know exactly how long it is */
|
||||
nbuf = safe_emalloc(buf_len, sizeof(char), 0);
|
||||
nbuf = safe_emalloc(new_l, 1, 1);
|
||||
strncpy(nbuf, buf, buf_len-1);
|
||||
efree(buf);
|
||||
buf = nbuf;
|
||||
@@ -556,7 +556,7 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
char *replace;
|
||||
char *ret;
|
||||
int arg_string_len;
|
||||
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZs", &arg_pattern, &arg_replace, &arg_string, &arg_string_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ static void php_do_ereg_replace(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
if (ret == (char *) -1) {
|
||||
RETVAL_FALSE;
|
||||
} else {
|
||||
RETVAL_STRING(ret, 1);
|
||||
RETVAL_STRINGL_CHECK(ret, strlen(ret), 1);
|
||||
STR_FREE(ret);
|
||||
}
|
||||
|
||||
@@ -664,9 +664,9 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
} else if (subs[0].rm_so == 0 && subs[0].rm_eo == 0) {
|
||||
/* No more matches */
|
||||
regfree(&re);
|
||||
|
||||
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Regular Expression");
|
||||
|
||||
|
||||
zend_hash_destroy(Z_ARRVAL_P(return_value));
|
||||
efree(Z_ARRVAL_P(return_value));
|
||||
RETURN_FALSE;
|
||||
@@ -675,7 +675,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
|
||||
/* make a copy of the substring */
|
||||
size = subs[0].rm_so;
|
||||
|
||||
|
||||
/* add it to the array */
|
||||
add_next_index_stringl(return_value, strp, size, 1);
|
||||
|
||||
@@ -701,7 +701,7 @@ static void php_split(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||
|
||||
/* otherwise we just have one last element to add to the array */
|
||||
size = endp - strp;
|
||||
|
||||
|
||||
add_next_index_stringl(return_value, strp, size, 1);
|
||||
|
||||
regfree(&re);
|
||||
@@ -738,9 +738,9 @@ PHP_EREG_API PHP_FUNCTION(sql_regcase)
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &string_len) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
tmp = safe_emalloc(string_len, 4, 1);
|
||||
|
||||
|
||||
for (i = j = 0; i < string_len; i++) {
|
||||
c = (unsigned char) string[i];
|
||||
if ( j >= INT_MAX - 1 || (isalpha(c) && j >= INT_MAX - 4)) {
|
||||
|
||||
@@ -3734,8 +3734,11 @@ static int exif_process_IFD_in_TIFF(image_info_type *ImageInfo, size_t dir_offse
|
||||
fgot = php_stream_read(ImageInfo->infile, ImageInfo->Thumbnail.data, ImageInfo->Thumbnail.size);
|
||||
if (fgot < ImageInfo->Thumbnail.size) {
|
||||
EXIF_ERRLOG_THUMBEOF(ImageInfo)
|
||||
efree(ImageInfo->Thumbnail.data);
|
||||
ImageInfo->Thumbnail.data = NULL;
|
||||
} else {
|
||||
exif_thumbnail_build(ImageInfo TSRMLS_CC);
|
||||
}
|
||||
exif_thumbnail_build(ImageInfo TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,8 +380,14 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
|
||||
|
||||
ce = Z_OBJCE_PP(value);
|
||||
if (!ce->__tostring) {
|
||||
ZVAL_FALSE(*value);
|
||||
return;
|
||||
zval_dtor(*value);
|
||||
/* #67167: doesn't return null on failure for objects */
|
||||
if (flags & FILTER_NULL_ON_FAILURE) {
|
||||
ZVAL_NULL(*value);
|
||||
} else {
|
||||
ZVAL_FALSE(*value);
|
||||
}
|
||||
goto handle_default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,6 +396,7 @@ static void php_zval_filter(zval **value, long filter, long flags, zval *options
|
||||
|
||||
filter_func.function(*value, flags, options, charset TSRMLS_CC);
|
||||
|
||||
handle_default:
|
||||
if (
|
||||
options && (Z_TYPE_P(options) == IS_ARRAY || Z_TYPE_P(options) == IS_OBJECT) &&
|
||||
((flags & FILTER_NULL_ON_FAILURE && Z_TYPE_PP(value) == IS_NULL) ||
|
||||
|
||||
@@ -704,8 +704,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
|
||||
if (flags & FILTER_FLAG_NO_PRIV_RANGE) {
|
||||
if (
|
||||
(ip[0] == 10) ||
|
||||
(ip[0] == 169 && ip[1] == 254) ||
|
||||
(ip[0] == 172 && (ip[1] >= 16 && ip[1] <= 31)) ||
|
||||
(ip[0] == 172 && ip[1] >= 16 && ip[1] <= 31) ||
|
||||
(ip[0] == 192 && ip[1] == 168)
|
||||
) {
|
||||
RETURN_VALIDATION_FAILED
|
||||
@@ -715,19 +714,9 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
|
||||
if (flags & FILTER_FLAG_NO_RES_RANGE) {
|
||||
if (
|
||||
(ip[0] == 0) ||
|
||||
(ip[0] == 10) ||
|
||||
(ip[0] == 100 && (ip[1] >= 64 && ip[1] <= 127)) ||
|
||||
(ip[0] >= 240) ||
|
||||
(ip[0] == 127) ||
|
||||
(ip[0] == 169 && ip[1] == 254) ||
|
||||
(ip[0] == 172 && (ip[1] >= 16 && ip[1] <= 31)) ||
|
||||
(ip[0] == 192 && ip[1] == 0 && ip[2] == 0) ||
|
||||
(ip[0] == 192 && ip[1] == 0 && ip[2] == 2) ||
|
||||
(ip[0] == 192 && ip[1] == 88 && ip[2] == 99) ||
|
||||
(ip[0] == 192 && ip[1] == 168) ||
|
||||
(ip[0] == 198 && (ip[1] == 18 || ip[1] == 19)) ||
|
||||
(ip[0] == 198 && ip[1] == 51 && ip[2] == 100) ||
|
||||
(ip[0] == 203 && ip[1] == 0 && ip[2] == 113) ||
|
||||
(ip[0] >= 224 && ip[0] <= 255)
|
||||
(ip[0] == 169 && ip[1] == 254)
|
||||
) {
|
||||
RETURN_VALIDATION_FAILED
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ string(9) "127.0.0.1"
|
||||
bool(false)
|
||||
string(12) "192.0.34.166"
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(9) "192.0.0.1"
|
||||
string(10) "100.64.0.0"
|
||||
string(15) "100.127.255.255"
|
||||
string(12) "192.0.34.166"
|
||||
bool(false)
|
||||
string(15) "255.255.255.255"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
Bug #67167: object with VALIDATE_BOOLEAN and NULL_ON_FAILURE
|
||||
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("filter")) die("skip"); ?>
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(filter_var(
|
||||
new \StdClass(),
|
||||
FILTER_VALIDATE_BOOLEAN,
|
||||
FILTER_NULL_ON_FAILURE
|
||||
));
|
||||
|
||||
--EXPECTF--
|
||||
NULL
|
||||
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #67167: filter_var(null,FILTER_VALIDATE_BOOLEAN,FILTER_NULL_ON_FAILURE) returns null
|
||||
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("filter")) die("skip"); ?>
|
||||
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(filter_var(
|
||||
null,
|
||||
FILTER_VALIDATE_BOOLEAN,
|
||||
FILTER_NULL_ON_FAILURE
|
||||
));
|
||||
|
||||
--XFAIL--
|
||||
Requires php_zval_filter to not use convert_to_string for all filters.
|
||||
|
||||
--EXPECTF--
|
||||
NULL
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
--TEST--
|
||||
Bug #73054 (default option ignored when object passed to int filter)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('filter')) die('skip filter extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(
|
||||
filter_var(new stdClass, FILTER_VALIDATE_INT, [
|
||||
'options' => ['default' => 2],
|
||||
]),
|
||||
filter_var(new stdClass, FILTER_VALIDATE_INT, [
|
||||
'options' => ['default' => 2],
|
||||
'flags' => FILTER_NULL_ON_FAILURE
|
||||
])
|
||||
);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
int(2)
|
||||
int(2)
|
||||
===DONE===
|
||||
@@ -85,8 +85,8 @@ string(10) "10.0.0.0/8"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(14) "168.254.0.0/16"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(11) "169.254.0.0"
|
||||
string(15) "169.254.255.255"
|
||||
string(13) "172.16.0.0/12"
|
||||
bool(false)
|
||||
bool(false)
|
||||
@@ -94,11 +94,11 @@ string(14) "192.168.0.0/16"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(10) "10.0.0.0/8"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(8) "10.0.0.0"
|
||||
string(14) "10.255.255.255"
|
||||
string(12) "10.64.0.0/10"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(10) "100.64.0.0"
|
||||
string(15) "100.127.255.255"
|
||||
string(11) "127.0.0.0/8"
|
||||
bool(false)
|
||||
bool(false)
|
||||
@@ -106,32 +106,32 @@ string(14) "169.254.0.0/16"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(13) "172.16.0.0/12"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(10) "172.16.0.0"
|
||||
string(10) "172.31.0.0"
|
||||
string(12) "192.0.0.0/24"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(9) "192.0.0.0"
|
||||
string(11) "192.0.0.255"
|
||||
string(12) "192.0.0.0/29"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(9) "192.0.0.0"
|
||||
string(9) "192.0.0.7"
|
||||
string(12) "192.0.2.0/24"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(9) "192.0.2.0"
|
||||
string(11) "192.0.2.255"
|
||||
string(13) "198.18.0.0/15"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(10) "198.18.0.0"
|
||||
string(14) "198.19.255.255"
|
||||
string(15) "198.51.100.0/24"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(12) "198.51.100.0"
|
||||
string(14) "198.51.100.255"
|
||||
string(14) "192.88.99.0/24"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(11) "192.88.99.0"
|
||||
string(13) "192.88.99.255"
|
||||
string(14) "192.168.0.0/16"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(11) "192.168.0.0"
|
||||
string(15) "192.168.255.255"
|
||||
string(14) "203.0.113.0/24"
|
||||
bool(false)
|
||||
bool(false)
|
||||
string(11) "203.0.113.0"
|
||||
string(13) "203.0.113.255"
|
||||
string(11) "240.0.0.0/4"
|
||||
bool(false)
|
||||
string(9) "224.0.0.0"
|
||||
bool(false)
|
||||
@@ -139,7 +139,10 @@ if ($pid) {
|
||||
$buf = fread($s, 2048);
|
||||
}
|
||||
|
||||
if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
|
||||
if ($buf == "AUTH TLS\r\n") {
|
||||
fputs($s, "500 not supported.\r\n");
|
||||
return ;
|
||||
} else if (!preg_match('/^USER (\w+)\r\n$/', $buf, $m)) {
|
||||
fputs($s, "500 Syntax error, command unrecognized.\r\n");
|
||||
dump_and_exit($buf);
|
||||
}
|
||||
@@ -208,6 +211,10 @@ if ($pid) {
|
||||
$ascii = true;
|
||||
fputs($s, "200 OK\r\n");
|
||||
|
||||
} elseif ($buf === "AUTH SSL\r\n") {
|
||||
$ascii = true;
|
||||
fputs($s, "500 not supported\r\n");
|
||||
|
||||
} elseif ($buf === "TYPE I\r\n") {
|
||||
$ascii = false;
|
||||
fputs($s, "200 OK\r\n");
|
||||
|
||||
@@ -1644,7 +1644,7 @@ PHP_FUNCTION(imageistruecolor)
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto void imagetruecolortopalette(resource im, bool ditherFlag, int colorsWanted)
|
||||
Convert a true colour image to a palette based image with a number of colours, optionally using dithering. */
|
||||
Convert a true color image to a palette based image with a number of colors, optionally using dithering. */
|
||||
PHP_FUNCTION(imagetruecolortopalette)
|
||||
{
|
||||
zval *IM;
|
||||
@@ -1670,8 +1670,8 @@ PHP_FUNCTION(imagetruecolortopalette)
|
||||
|
||||
|
||||
|
||||
/* {{{ proto void imagetruecolortopalette(resource im, bool ditherFlag, int colorsWanted)
|
||||
Convert a true colour image to a palette based image with a number of colours, optionally using dithering. */
|
||||
/* {{{ proto void imagepalettetotruecolor(resource im)
|
||||
Convert a palette based image to a true color image. */
|
||||
PHP_FUNCTION(imagepalettetotruecolor)
|
||||
{
|
||||
zval *IM;
|
||||
@@ -2614,11 +2614,11 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
|
||||
|
||||
if (argc > 1) {
|
||||
fn = file;
|
||||
if (argc == 3) {
|
||||
if (argc >= 3) {
|
||||
q = quality;
|
||||
}
|
||||
if (argc == 4) {
|
||||
t = type;
|
||||
if (argc == 4) {
|
||||
t = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3854,7 +3854,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int
|
||||
{
|
||||
zval *IM, *EXT = NULL;
|
||||
gdImagePtr im=NULL;
|
||||
long col = -1, x = -1, y = -1;
|
||||
long col = -1, x = 0, y = 0;
|
||||
int str_len, fontname_len, i, brect[8];
|
||||
double ptsize, angle;
|
||||
char *str = NULL, *fontname = NULL;
|
||||
@@ -4530,6 +4530,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
dest = VCWD_FOPEN(fn_dest, "wb");
|
||||
if (!dest) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' for writing", fn_dest);
|
||||
fclose(org);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -4538,6 +4539,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_org = gdImageCreateFromGif(org);
|
||||
if (im_org == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid GIF file", fn_dest);
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -4548,6 +4551,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_org = gdImageCreateFromJpegEx(org, ignore_warning);
|
||||
if (im_org == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid JPEG file", fn_dest);
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -4558,6 +4563,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_org = gdImageCreateFromPng(org);
|
||||
if (im_org == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open '%s' Not a valid PNG file", fn_dest);
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
@@ -4565,10 +4572,14 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
|
||||
default:
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Format not supported");
|
||||
fclose(org);
|
||||
fclose(dest);
|
||||
RETURN_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
fclose(org);
|
||||
|
||||
org_width = gdImageSX (im_org);
|
||||
org_height = gdImageSY (im_org);
|
||||
|
||||
@@ -4599,6 +4610,8 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
im_tmp = gdImageCreate (dest_width, dest_height);
|
||||
if (im_tmp == NULL ) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate temporary buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_org);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
@@ -4606,23 +4619,29 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
|
||||
|
||||
gdImageDestroy(im_org);
|
||||
|
||||
fclose(org);
|
||||
|
||||
im_dest = gdImageCreate(dest_width, dest_height);
|
||||
if (im_dest == NULL) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate destination buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_tmp);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
white = gdImageColorAllocate(im_dest, 255, 255, 255);
|
||||
if (white == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate the colors for the destination buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_tmp);
|
||||
gdImageDestroy(im_dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
black = gdImageColorAllocate(im_dest, 0, 0, 0);
|
||||
if (black == -1) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate the colors for the destination buffer");
|
||||
fclose(dest);
|
||||
gdImageDestroy(im_tmp);
|
||||
gdImageDestroy(im_dest);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -2247,7 +2247,9 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
|
||||
for (y = 0; (y < h); y++) {
|
||||
for (x = 0; (x < w); x++) {
|
||||
int c = gdImageGetTrueColorPixel (src, srcX + x, srcY + y);
|
||||
gdImageSetPixel (dst, dstX + x, dstY + y, c);
|
||||
if (c != src->transparent) {
|
||||
gdImageSetPixel (dst, dstX + x, dstY + y, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -2264,26 +2266,6 @@ void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX,
|
||||
return;
|
||||
}
|
||||
|
||||
/* Destination is palette based */
|
||||
if (src->trueColor) { /* But source is truecolor (Ouch!) */
|
||||
toy = dstY;
|
||||
for (y = srcY; (y < (srcY + h)); y++) {
|
||||
tox = dstX;
|
||||
for (x = srcX; x < (srcX + w); x++) {
|
||||
int nc;
|
||||
c = gdImageGetPixel (src, x, y);
|
||||
|
||||
/* Get best match possible. */
|
||||
nc = gdImageColorResolveAlpha(dst, gdTrueColorGetRed(c), gdTrueColorGetGreen(c), gdTrueColorGetBlue(c), gdTrueColorGetAlpha(c));
|
||||
|
||||
gdImageSetPixel(dst, tox, toy, nc);
|
||||
tox++;
|
||||
}
|
||||
toy++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Palette based to palette based */
|
||||
for (i = 0; i < gdMaxColors; i++) {
|
||||
colorMap[i] = (-1);
|
||||
|
||||
@@ -191,21 +191,21 @@ static gdImagePtr _gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy, int *cs,
|
||||
}
|
||||
if (im == NULL) {
|
||||
GD2_DBG(php_gd_error("Could not create gdImage"));
|
||||
goto fail1;
|
||||
goto fail2;
|
||||
}
|
||||
|
||||
if (!_gdGetColors(in, im, (*vers) == 2)) {
|
||||
GD2_DBG(php_gd_error("Could not read color palette"));
|
||||
goto fail2;
|
||||
goto fail3;
|
||||
}
|
||||
GD2_DBG(php_gd_error("Image palette completed: %d colours", im->colorsTotal));
|
||||
|
||||
return im;
|
||||
|
||||
fail2:
|
||||
fail3:
|
||||
gdImageDestroy(im);
|
||||
return 0;
|
||||
|
||||
fail2:
|
||||
gdFree(*cidx);
|
||||
fail1:
|
||||
return 0;
|
||||
}
|
||||
@@ -670,7 +670,7 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||
|
||||
/* Force fmt to a valid value since we don't return anything. */
|
||||
if ((fmt != GD2_FMT_RAW) && (fmt != GD2_FMT_COMPRESSED)) {
|
||||
fmt = im->trueColor ? GD2_FMT_TRUECOLOR_COMPRESSED : GD2_FMT_COMPRESSED;
|
||||
fmt = GD2_FMT_COMPRESSED;
|
||||
}
|
||||
if (im->trueColor) {
|
||||
fmt += 2;
|
||||
@@ -689,8 +689,8 @@ static void _gdImageGd2 (gdImagePtr im, gdIOCtx * out, int cs, int fmt)
|
||||
}
|
||||
|
||||
/* Work out number of chunks. */
|
||||
ncx = im->sx / cs + 1;
|
||||
ncy = im->sy / cs + 1;
|
||||
ncx = (im->sx + cs - 1) / cs;
|
||||
ncy = (im->sy + cs - 1) / cs;
|
||||
|
||||
/* Write the standard header. */
|
||||
_gd2PutHeader (im, out, cs, fmt, ncx, ncy);
|
||||
|
||||
@@ -760,7 +760,7 @@ LOCAL (void)
|
||||
cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total >> 1)) / total);
|
||||
#else
|
||||
/* 2.0.16: Paul den Dulk found an occasion where total can be 0 */
|
||||
if (count)
|
||||
if (total)
|
||||
{
|
||||
nim->red[icolor] = (int) ((c0total + (total >> 1)) / total);
|
||||
nim->green[icolor] = (int) ((c1total + (total >> 1)) / total);
|
||||
|
||||
@@ -180,6 +180,15 @@ void gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quantization)
|
||||
/* Conversion to Y,U,V buffer */
|
||||
yuv_width = (width + 1) >> 1;
|
||||
yuv_height = (height + 1) >> 1;
|
||||
|
||||
if (overflow2(width, height)) {
|
||||
return;
|
||||
}
|
||||
/* simplification possible, because WebP must not be larger than 16384**2 */
|
||||
if (overflow2(width * height, 2 * sizeof(unsigned char))) {
|
||||
return;
|
||||
}
|
||||
|
||||
yuv_nbytes = width * height + 2 * yuv_width * yuv_height;
|
||||
|
||||
if ((Y = (unsigned char *)gdCalloc(yuv_nbytes, sizeof(unsigned char))) == NULL) {
|
||||
|
||||
@@ -659,6 +659,8 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg,
|
||||
} else {
|
||||
return "Unsupported ft_pixel_mode";
|
||||
}
|
||||
if (level == 0) /* if background */
|
||||
continue;
|
||||
if ((fg >= 0) && (im->trueColor)) {
|
||||
/* Consider alpha in the foreground color itself to be an
|
||||
* upper bound on how opaque things get, when truecolor is
|
||||
@@ -748,9 +750,9 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg,
|
||||
}
|
||||
|
||||
static int
|
||||
gdroundupdown (FT_F26Dot6 v1, int updown)
|
||||
gdroundupdown (FT_F26Dot6 v1, int roundup)
|
||||
{
|
||||
return (!updown) ? (v1 < 0 ? ((v1 - 63) >> 6) : v1 >> 6) : (v1 > 0 ? ((v1 + 63) >> 6) : v1 >> 6);
|
||||
return (!roundup) ? v1 >> 6 : (v1 + 63) >> 6;
|
||||
}
|
||||
|
||||
void gdFontCacheShutdown()
|
||||
@@ -820,8 +822,6 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
double cos_a = cos (angle);
|
||||
int len, i = 0, ch;
|
||||
int x1 = 0, y1 = 0;
|
||||
int xb = x, yb = y;
|
||||
int yd = 0;
|
||||
font_t *font;
|
||||
fontkey_t fontkey;
|
||||
char *next;
|
||||
@@ -982,9 +982,6 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
penf.y = (penf.y - 32) & -64; /* round to next pixel row */
|
||||
x1 = (int)(- penf.y * sin_a + 32) / 64;
|
||||
y1 = (int)(- penf.y * cos_a + 32) / 64;
|
||||
xb = x + x1;
|
||||
yb = y + y1;
|
||||
yd = 0;
|
||||
pen.x = pen.y = 0;
|
||||
previous = 0; /* clear kerning flag */
|
||||
continue;
|
||||
@@ -1074,23 +1071,32 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
/* retrieve kerning distance and move pen position */
|
||||
if (use_kerning && previous && glyph_index) {
|
||||
FT_Get_Kerning(face, previous, glyph_index, ft_kerning_default, &delta);
|
||||
pen.x += delta.x;
|
||||
pen.x += (int)(delta.x * cos_a);
|
||||
pen.y -= (int)(delta.x * sin_a);
|
||||
penf.x += delta.x;
|
||||
}
|
||||
|
||||
/* load glyph image into the slot (erase previous one) */
|
||||
if (FT_Load_Glyph(face, glyph_index, render_mode)) {
|
||||
if (tmpstr) {
|
||||
gdFree(tmpstr);
|
||||
}
|
||||
gdCacheDelete(tc_cache);
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
return "Problem loading glyph";
|
||||
}
|
||||
|
||||
/* transform glyph image */
|
||||
FT_Get_Glyph(slot, &image);
|
||||
if (brect) { /* only if need brect */
|
||||
/* load glyph image into the slot (erase previous one) */
|
||||
if (FT_Load_Glyph(face, glyph_index, render_mode | FT_LOAD_IGNORE_TRANSFORM)) {
|
||||
if (tmpstr) {
|
||||
gdFree(tmpstr);
|
||||
}
|
||||
gdCacheDelete(tc_cache);
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
return "Problem loading glyph";
|
||||
}
|
||||
|
||||
/* transform glyph image */
|
||||
if (FT_Get_Glyph(slot, &image)) {
|
||||
if (tmpstr) {
|
||||
gdFree(tmpstr);
|
||||
}
|
||||
gdCacheDelete(tc_cache);
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
return "Problem loading glyph";
|
||||
}
|
||||
|
||||
FT_Glyph_Get_CBox(image, ft_glyph_bbox_gridfit, &glyph_bbox);
|
||||
glyph_bbox.xMin += penf.x;
|
||||
glyph_bbox.yMin += penf.y;
|
||||
@@ -1100,17 +1106,11 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
glyph_bbox.xMax += slot->metrics.horiAdvance;
|
||||
}
|
||||
if (!i) { /* if first character, init BB corner values */
|
||||
yd = slot->metrics.height - slot->metrics.horiBearingY;
|
||||
bbox.xMin = glyph_bbox.xMin;
|
||||
bbox.yMin = glyph_bbox.yMin;
|
||||
bbox.xMax = glyph_bbox.xMax;
|
||||
bbox.yMax = glyph_bbox.yMax;
|
||||
} else {
|
||||
FT_Pos desc;
|
||||
|
||||
if ( (desc = (slot->metrics.height - slot->metrics.horiBearingY)) > yd) {
|
||||
yd = desc;
|
||||
}
|
||||
if (bbox.xMin > glyph_bbox.xMin) {
|
||||
bbox.xMin = glyph_bbox.xMin;
|
||||
}
|
||||
@@ -1127,7 +1127,35 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
i++;
|
||||
}
|
||||
|
||||
/* increment (unrotated) pen position */
|
||||
penf.x += slot->metrics.horiAdvance;
|
||||
|
||||
if (render) {
|
||||
if (!brect || angle != 0) {
|
||||
/* reload the rotated glyph (for bbox we needed FT_LOAD_IGNORE_TRANSFORM - bbox is rotated later) */
|
||||
FT_Done_Glyph(image);
|
||||
|
||||
/* load glyph image into the slot (erase previous one) */
|
||||
if (FT_Load_Glyph(face, glyph_index, render_mode)) {
|
||||
if (tmpstr) {
|
||||
gdFree(tmpstr);
|
||||
}
|
||||
gdCacheDelete(tc_cache);
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
return "Problem loading glyph";
|
||||
}
|
||||
|
||||
/* transform glyph image */
|
||||
if (FT_Get_Glyph(slot, &image)) {
|
||||
if (tmpstr) {
|
||||
gdFree(tmpstr);
|
||||
}
|
||||
gdCacheDelete(tc_cache);
|
||||
gdMutexUnlock(gdFontCacheMutex);
|
||||
return "Problem loading glyph";
|
||||
}
|
||||
}
|
||||
|
||||
if (image->format != ft_glyph_format_bitmap && FT_Glyph_To_Bitmap(&image, ft_render_mode_normal, 0, 1)) {
|
||||
FT_Done_Glyph(image);
|
||||
if (tmpstr) {
|
||||
@@ -1150,8 +1178,6 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
pen.x += image->advance.x >> 10;
|
||||
pen.y -= image->advance.y >> 10;
|
||||
|
||||
penf.x += slot->metrics.horiAdvance;
|
||||
|
||||
FT_Done_Glyph(image);
|
||||
}
|
||||
|
||||
@@ -1160,36 +1186,25 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
|
||||
double d1 = sin (angle + 0.78539816339744830962);
|
||||
double d2 = sin (angle - 0.78539816339744830962);
|
||||
|
||||
/* make the center of rotation at (0, 0) */
|
||||
FT_BBox normbox;
|
||||
|
||||
normbox.xMin = 0;
|
||||
normbox.yMin = 0;
|
||||
normbox.xMax = bbox.xMax - bbox.xMin;
|
||||
normbox.yMax = bbox.yMax - bbox.yMin;
|
||||
|
||||
brect[0] = brect[2] = brect[4] = brect[6] = (int) (yd * sin_a);
|
||||
brect[1] = brect[3] = brect[5] = brect[7] = (int)(- yd * cos_a);
|
||||
|
||||
/* rotate bounding rectangle */
|
||||
brect[0] += (int) (normbox.xMin * cos_a - normbox.yMin * sin_a);
|
||||
brect[1] += (int) (normbox.xMin * sin_a + normbox.yMin * cos_a);
|
||||
brect[2] += (int) (normbox.xMax * cos_a - normbox.yMin * sin_a);
|
||||
brect[3] += (int) (normbox.xMax * sin_a + normbox.yMin * cos_a);
|
||||
brect[4] += (int) (normbox.xMax * cos_a - normbox.yMax * sin_a);
|
||||
brect[5] += (int) (normbox.xMax * sin_a + normbox.yMax * cos_a);
|
||||
brect[6] += (int) (normbox.xMin * cos_a - normbox.yMax * sin_a);
|
||||
brect[7] += (int) (normbox.xMin * sin_a + normbox.yMax * cos_a);
|
||||
/* rotate bounding rectangle (at 0, 0) */
|
||||
brect[0] = (int) (bbox.xMin * cos_a - bbox.yMin * sin_a);
|
||||
brect[1] = (int) (bbox.xMin * sin_a + bbox.yMin * cos_a);
|
||||
brect[2] = (int) (bbox.xMax * cos_a - bbox.yMin * sin_a);
|
||||
brect[3] = (int) (bbox.xMax * sin_a + bbox.yMin * cos_a);
|
||||
brect[4] = (int) (bbox.xMax * cos_a - bbox.yMax * sin_a);
|
||||
brect[5] = (int) (bbox.xMax * sin_a + bbox.yMax * cos_a);
|
||||
brect[6] = (int) (bbox.xMin * cos_a - bbox.yMax * sin_a);
|
||||
brect[7] = (int) (bbox.xMin * sin_a + bbox.yMax * cos_a);
|
||||
|
||||
/* scale, round and offset brect */
|
||||
brect[0] = xb + gdroundupdown(brect[0], d2 > 0);
|
||||
brect[1] = yb - gdroundupdown(brect[1], d1 < 0);
|
||||
brect[2] = xb + gdroundupdown(brect[2], d1 > 0);
|
||||
brect[3] = yb - gdroundupdown(brect[3], d2 > 0);
|
||||
brect[4] = xb + gdroundupdown(brect[4], d2 < 0);
|
||||
brect[5] = yb - gdroundupdown(brect[5], d1 > 0);
|
||||
brect[6] = xb + gdroundupdown(brect[6], d1 < 0);
|
||||
brect[7] = yb - gdroundupdown(brect[7], d2 < 0);
|
||||
brect[0] = x + gdroundupdown(brect[0], d2 > 0);
|
||||
brect[1] = y - gdroundupdown(brect[1], d1 < 0);
|
||||
brect[2] = x + gdroundupdown(brect[2], d1 > 0);
|
||||
brect[3] = y - gdroundupdown(brect[3], d2 > 0);
|
||||
brect[4] = x + gdroundupdown(brect[4], d2 < 0);
|
||||
brect[5] = y - gdroundupdown(brect[5], d1 > 0);
|
||||
brect[6] = x + gdroundupdown(brect[6], d1 < 0);
|
||||
brect[7] = y - gdroundupdown(brect[7], d2 < 0);
|
||||
}
|
||||
|
||||
if (tmpstr) {
|
||||
|
||||
@@ -8,16 +8,13 @@ Bug #22544 (TrueColor transparency in PNG images).
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$dest = dirname(realpath(__FILE__)) . '/bug22544.png';
|
||||
@unlink($dest);
|
||||
$image = imageCreateTruecolor(640, 100);
|
||||
$transparent = imageColorAllocate($image, 0, 0, 0);
|
||||
$red = imageColorAllocate($image, 255, 50, 50);
|
||||
imageColorTransparent($image, $transparent);
|
||||
imageFilledRectangle($image, 0, 0, 640-1, 100-1, $transparent);
|
||||
imagegd($image, $dest);
|
||||
echo md5_file($dest) . "\n";
|
||||
@unlink($dest);
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/bug22544.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
7643ef115f642a79c2de6e411f485ddd
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 284 B |
@@ -1,29 +1,53 @@
|
||||
--TEST--
|
||||
Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype < 2.4.10
|
||||
Bug #43073 (TrueType bounding box is wrong for angle<>0)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imagettftext')) die('skip imagettftext() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$exp = [
|
||||
[501,400, 611,400, 611,376, 501,376],
|
||||
[492,361, 595,319, 586,296, 483,338],
|
||||
[470,329, 549,251, 531,233, 453,312],
|
||||
[439,307, 481,204, 458,195, 416,297],
|
||||
[400,299, 400,189, 376,189, 376,299],
|
||||
[361,307, 319,204, 296,213, 338,316],
|
||||
[329,329, 251,250, 233,267, 311,346],
|
||||
[307,360, 204,318, 195,341, 297,383],
|
||||
[299,400, 189,400, 189,424, 299,424],
|
||||
[307,438, 204,480, 213,503, 316,461],
|
||||
[329,470, 250,548, 267,566, 346,488],
|
||||
[360,492, 318,595, 341,604, 383,502],
|
||||
[400,501, 400,611, 424,611, 424,501],
|
||||
[438,492, 480,595, 503,586, 461,483],
|
||||
[470,470, 548,549, 566,532, 488,453],
|
||||
[492,439, 595,481, 604,458, 502,416]
|
||||
];
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.ttf";
|
||||
$delta_t = 360.0 / 16; # Make 16 steps around
|
||||
$g = imagecreate(800, 800);
|
||||
$bgnd = imagecolorallocate($g, 255, 255, 255);
|
||||
$black = imagecolorallocate($g, 0, 0, 0);
|
||||
$red = imagecolorallocate($g, 255, 0, 0);
|
||||
$x = 100;
|
||||
$y = 0;
|
||||
$cos_t = cos(deg2rad($delta_t));
|
||||
$sin_t = sin(deg2rad($delta_t));
|
||||
for ($angle = 0.0; $angle < 360.0; $angle += $delta_t) {
|
||||
for ($angle = 0.0, $i = 0; $angle < 360.0; $angle += $delta_t, $i++) {
|
||||
$bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF');
|
||||
$s = vsprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox);
|
||||
echo $s;
|
||||
imagepolygon($g, $bbox, 4, $red);
|
||||
printf("%2d: ", $i);
|
||||
for ($j = 0; $j < 8; $j++) {
|
||||
if ($bbox[$j] >= $exp[$i][$j] - 1 && $bbox[$j] <= $exp[$i][$j] + 1) {
|
||||
echo '.';
|
||||
} else {
|
||||
echo "(expected $exp[$i][$j], got $bbox[$j])";
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
$temp = $cos_t * $x + $sin_t * $y;
|
||||
$y = $cos_t * $y - $sin_t * $x;
|
||||
$x = $temp;
|
||||
@@ -32,20 +56,20 @@ imagepng($g, "$cwd/bug43073.png");
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?>
|
||||
--EXPECTF--
|
||||
(500, 40%d), (610, 40%d), (610, 376), (500, 376)
|
||||
(492, 363), (591, 322), (580, 295), (480, 336)
|
||||
(470, 331), (548, 254), (527, 233), (449, 310)
|
||||
(439, 309), (483, 202), (461, 193), (416, 299)
|
||||
(40%d, 300), (40%d, 183), (38%d, 183), (38%d, 300)
|
||||
(362, 307), (316, 195), (291, 205), (337, 318)
|
||||
(330, 329), (246, 244), (224, 265), (308, 350)
|
||||
(308, 360), (202, 316), (190, 344), (296, 388)
|
||||
(300, %d), (18%d, %d), (18%d, 425), (%d, 425)
|
||||
(306, 437), (195, 483), (206, 510), (318, 464)
|
||||
(328, 469), (240, 557), (260, 578), (349, 491)
|
||||
(359, 491), (312, 607), (334, 616), (382, 501)
|
||||
(%d, 500), (%d, 618), (41%d, 618), (41%d, 500)
|
||||
(436, 493), (483, 607), (507, 597), (461, 482)
|
||||
(468, 471), (555, 558), (577, 538), (490, 450)
|
||||
(490, 440), (600, 485), (611, 457), (502, 412)
|
||||
--EXPECT--
|
||||
0: ........
|
||||
1: ........
|
||||
2: ........
|
||||
3: ........
|
||||
4: ........
|
||||
5: ........
|
||||
6: ........
|
||||
7: ........
|
||||
8: ........
|
||||
9: ........
|
||||
10: ........
|
||||
11: ........
|
||||
12: ........
|
||||
13: ........
|
||||
14: ........
|
||||
15: ........
|
||||
@@ -1,51 +0,0 @@
|
||||
--TEST--
|
||||
Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype >= 2.4.10
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imagettftext')) die('skip imagettftext() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.ttf";
|
||||
$delta_t = 360.0 / 16; # Make 16 steps around
|
||||
$g = imagecreate(800, 800);
|
||||
$bgnd = imagecolorallocate($g, 255, 255, 255);
|
||||
$black = imagecolorallocate($g, 0, 0, 0);
|
||||
$x = 100;
|
||||
$y = 0;
|
||||
$cos_t = cos(deg2rad($delta_t));
|
||||
$sin_t = sin(deg2rad($delta_t));
|
||||
for ($angle = 0.0; $angle < 360.0; $angle += $delta_t) {
|
||||
$bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF');
|
||||
$s = vsprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox);
|
||||
echo $s;
|
||||
$temp = $cos_t * $x + $sin_t * $y;
|
||||
$y = $cos_t * $y - $sin_t * $x;
|
||||
$x = $temp;
|
||||
}
|
||||
imagepng($g, "$cwd/bug43073.png");
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?>
|
||||
--EXPECTF--
|
||||
(500, 400), (610, 400), (610, 376), (500, 376)
|
||||
(492, 363), (591, 322), (580, 295), (480, 336)
|
||||
(470, 331), (548, 254), (527, 233), (449, 310)
|
||||
(439, 309), (483, 202), (461, 193), (416, 299)
|
||||
(400, 300), (400, 183), (380, 183), (380, 300)
|
||||
(362, 307), (316, 195), (291, 205), (337, 318)
|
||||
(330, 329), (246, 244), (224, 265), (308, 350)
|
||||
(308, 360), (202, 316), (190, 344), (296, 388)
|
||||
(300, 400), (187, 400), (187, 425), (300, 425)
|
||||
(306, 437), (195, 483), (206, 510), (318, 464)
|
||||
(328, 469), (240, 557), (260, 578), (349, 491)
|
||||
(359, 491), (312, 607), (334, 616), (382, 501)
|
||||
(400, 500), (400, 618), (419, 618), (419, 500)
|
||||
(436, 493), (483, 607), (507, 597), (461, 482)
|
||||
(468, 471), (555, 558), (577, 538), (490, 450)
|
||||
(490, 440), (600, 485), (611, 457), (502, 412)
|
||||
@@ -17,10 +17,10 @@ imagefilledrectangle($im, 0,0, 99,99, $transparent);
|
||||
$color = imagecolorallocatealpha($im, 0, 255, 0, 100);
|
||||
imagefilledarc($im, 49, 49, 99,99, 0 , 360, $color, IMG_ARC_PIE);
|
||||
|
||||
ob_start();
|
||||
imagegd($im);
|
||||
echo md5(ob_get_clean());
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/bug43828.png', $im);
|
||||
|
||||
imagedestroy($im);
|
||||
?>
|
||||
--EXPECT--
|
||||
2400a58cd7570b5472c25264715321cd
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 656 B |
@@ -19,4 +19,4 @@ echo 'Left Bottom: (' . $bbox[0] . ', ' . $bbox[1] . ')';
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug48732.png'); ?>
|
||||
--EXPECTF--
|
||||
Left Bottom: (0, 47)
|
||||
Left Bottom: (0, 46)
|
||||
@@ -1,12 +1,9 @@
|
||||
--TEST--
|
||||
Bug #48801 (Problem with imagettfbbox) freetype < 2.4.10
|
||||
Bug #48801 (Problem with imagettfbbox)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
@@ -18,8 +15,8 @@ echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
|
||||
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
|
||||
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
(-1, 15)
|
||||
(15%d, 15)
|
||||
(15%d, -48)
|
||||
(-1, -48)
|
||||
--EXPECTREGEX--
|
||||
\(4, 15\)
|
||||
\(16[0-1], 15\)
|
||||
\(16[0-1], -4[7-8]\)
|
||||
\(4, -4[7-8]\)
|
||||
@@ -1,25 +0,0 @@
|
||||
--TEST--
|
||||
Bug #48801 (Problem with imagettfbbox) freetype >= 2.4.10
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
|
||||
include dirname(__FILE__) . '/func.inc';
|
||||
if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.ttf";
|
||||
$bbox = imageftbbox(50, 0, $font, "image");
|
||||
echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n";
|
||||
echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
|
||||
echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
|
||||
echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
(-1, 15)
|
||||
(15%d, 15)
|
||||
(15%d, -48)
|
||||
(-1, -48)
|
||||
@@ -0,0 +1,38 @@
|
||||
--TEST--
|
||||
Bug #50194 (imagettftext broken on transparent background w/o alphablending)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
if (!function_exists('imagettftext')) die('skip imagettftext() not available');
|
||||
//die('skip freetype issues');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'func.inc';
|
||||
|
||||
$im = imagecreatetruecolor(240, 55);
|
||||
$background = imagecolorallocatealpha($im, 60, 60, 60, 0); // no tranparency
|
||||
$black = imagecolorallocate($im, 0, 0, 0);
|
||||
imagealphablending($im, false);
|
||||
imagefilledrectangle($im, 0, 0, 239, 54, $background);
|
||||
$text = 'Testing ... ';
|
||||
$font = __DIR__ . DIRECTORY_SEPARATOR . 'Tuffy.ttf';
|
||||
imagettftext($im, 40, 0, 10, 40, $black, $font, $text);
|
||||
imagesavealpha($im, true);
|
||||
|
||||
ob_start();
|
||||
test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'bug50194.png', $im);
|
||||
$output = ob_get_clean();
|
||||
assert(preg_match('/The images are equal|The images differ in (\d+) pixels/', $output, $matches));
|
||||
if (isset($matches[1]) && $matches[1] > 2000) {
|
||||
echo "The images differ in {$matches[1]} pixels.\n";
|
||||
} else {
|
||||
echo "The images are similar.\n";
|
||||
}
|
||||
|
||||
imagedestroy($im);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
The images are similar.
|
||||
===DONE===
|
||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -3,6 +3,9 @@ Bug #53156 (imagerectangle problem with point ordering)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.3', '<')) {
|
||||
die("skip test requires GD 2.3 or newer");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
--TEST--
|
||||
Bug #53504 imagettfbbox/imageftbbox gives incorrect values for bounding box
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!extension_loaded('gd')){ die('skip gd extension not available'); }
|
||||
if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$cwd = dirname(__FILE__);
|
||||
$font = "$cwd/Tuffy.ttf";
|
||||
|
||||
$g = imagecreate(800, 800);
|
||||
$bgnd = imagecolorallocate($g, 255, 255, 255);
|
||||
$black = imagecolorallocate($g, 0, 0, 0);
|
||||
$red = imagecolorallocate($g, 255, 0, 0);
|
||||
$blue = imagecolorallocate($g, 0, 0, 255);
|
||||
|
||||
$tests = [
|
||||
// Kerning examples (unfortunately not available in "Tuffy" test font):
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 20, 'y' => 70, 'text' => 'AV Teg', 'exp' => [2,15, 208,15, 208,-48, 2,-48]],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 70, 'y' => 350, 'text' => 'AV Teg', 'exp' => [15,-1, 15,-208, -48,-208, -48,-2]],
|
||||
['fontSize' => 50, 'angle' => 40, 'x' => 130, 'y' => 280, 'text' => 'AV Teg', 'exp' => [11,11, 169,-122, 129,-171, -30,-39]],
|
||||
|
||||
// Shift-Test:
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 350, 'y' => 110, 'text' => 'H-Shift', 'exp' => [8,2, 386,2, 386,-97, 8,-97]],
|
||||
|
||||
// Small/single chars:
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 350, 'y' => 220, 'text' => '-', 'exp' => [7,-37, 51,-37, 51,-46, 7,-46]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 430, 'y' => 220, 'text' => ',', 'exp' => [7,15, 21,15, 21,-13, 7,-13]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 510, 'y' => 220, 'text' => '.', 'exp' => [7,1, 21,1, 21,-13, 7,-13]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 590, 'y' => 220, 'text' => '|', 'exp' => [8,0, 17,0, 17,-95, 8,-95]],
|
||||
['fontSize' => 100, 'angle' => 0, 'x' => 670, 'y' => 220, 'text' => 'g', 'exp' => [5,29, 60,29, 60,-72, 5,-72]],
|
||||
|
||||
// Multi-Line + rotation:
|
||||
['fontSize' => 30, 'angle' => 0, 'x' => 20, 'y' => 400, 'text' => "Multi\nLine\nTest", 'exp' => [2,107, 80,107, 80,-29, 2,-29]],
|
||||
['fontSize' => 30, 'angle' => 40, 'x' => 150, 'y' => 420, 'text' => "Multi\nLine\nTest", 'exp' => [70,81, 131,31, 43,-74, -18,-24]],
|
||||
['fontSize' => 30, 'angle' => 90, 'x' => 250, 'y' => 340, 'text' => "Multi\nLine\nTest", 'exp' => [107,-1, 107,-80, -29,-80, -29,-2]],
|
||||
|
||||
// Some edge case glyphs:
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 70, 'y' => 750, 'text' => "iiiiiiiiiiii", 'exp' => [0,-4, 0,-165, -47,-165, -47,-4]],
|
||||
['fontSize' => 50, 'angle' => 90, 'x' => 150, 'y' => 750, 'text' => "~~~~~~~", 'exp' => [-19,-2, -18,-167, -29,-167, -29,-2]],
|
||||
['fontSize' => 50, 'angle' => 50, 'x' => 210, 'y' => 750, 'text' => "iiiiiiiiiiii", 'exp' => [3,-3, 107,-127, 70,-157, -34,-33]],
|
||||
['fontSize' => 50, 'angle' => 50, 'x' => 300, 'y' => 750, 'text' => "~~~~~~~", 'exp' => [-13,-13, 93,-141, 85,-147, -21,-20]],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 430, 'y' => 650, 'text' => "iiiiiiiiiiii", 'exp' => [4,0, 165,0, 165,-47, 4,-47]],
|
||||
['fontSize' => 50, 'angle' => 0, 'x' => 430, 'y' => 750, 'text' => "~~~~~~~", 'exp' => [2,-19, 167,-19, 167,-29, 2,-29]],
|
||||
|
||||
// "Big" test:
|
||||
['fontSize' => 200, 'angle' => 0, 'x' => 400, 'y' => 500, 'text' => "Big", 'exp' => [16,59, 329,59, 329,-190, 16,-190]],
|
||||
];
|
||||
|
||||
foreach ($tests as $testnum => $test) {
|
||||
$bbox = imageftbbox($test['fontSize'], $test['angle'], $font, $test['text']);
|
||||
printf('%2d: ', $testnum);
|
||||
for ($i = 0; $i < 8; $i++) {
|
||||
$exp = $test['exp'][$i];
|
||||
if ($bbox[$i] >= $exp - 2 && $bbox[$i] <= $exp + 2) {
|
||||
echo '.';
|
||||
} else {
|
||||
echo "(expected $exp, got $bbox[$i])";
|
||||
}
|
||||
}
|
||||
echo "\n";
|
||||
|
||||
$bboxDrawn = imagefttext($g, $test['fontSize'], $test['angle'],
|
||||
$test['x'], $test['y'], $black, $font, $test['text']);
|
||||
|
||||
// check if both bboxes match when adding x/y offset:
|
||||
for ($i = 0; $i < count($bbox); $i += 2) {
|
||||
if ($bbox[$i] + $test['x'] !== $bboxDrawn[$i]) echo "imageftbbox and imagefttext differ!\n";
|
||||
if ($bbox[$i + 1] + $test['y'] !== $bboxDrawn[$i + 1]) echo "imageftbbox and imagefttext differ!\n";
|
||||
}
|
||||
|
||||
// draw bounding box:
|
||||
imagepolygon($g, $bboxDrawn, 4, $red);
|
||||
|
||||
// draw baseline:
|
||||
$width = sqrt(pow($bboxDrawn[2] - $bboxDrawn[0], 2) + pow($bboxDrawn[3] - $bboxDrawn[1], 2));
|
||||
imageline($g, $test['x'], $test['y'],
|
||||
$test['x'] + $width * cos(deg2rad($test['angle'])),
|
||||
$test['y'] - $width * sin(deg2rad($test['angle'])), $blue);
|
||||
}
|
||||
|
||||
imagepng($g, "$cwd/bug53504.png");
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php @unlink(dirname(__FILE__) . '/bug53504.png'); ?>
|
||||
--EXPECT--
|
||||
0: ........
|
||||
1: ........
|
||||
2: ........
|
||||
3: ........
|
||||
4: ........
|
||||
5: ........
|
||||
6: ........
|
||||
7: ........
|
||||
8: ........
|
||||
9: ........
|
||||
10: ........
|
||||
11: ........
|
||||
12: ........
|
||||
13: ........
|
||||
14: ........
|
||||
15: ........
|
||||
16: ........
|
||||
17: ........
|
||||
18: ........
|
||||
@@ -0,0 +1,34 @@
|
||||
--TEST--
|
||||
Bug #66005 (imagecopy does not support 1bit transparency on truecolor images)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$dest = imagecreatetruecolor(150, 50);
|
||||
$transparent = imagecolorallocatealpha($dest, 255, 255, 255, 127);
|
||||
imagealphablending($dest, false);
|
||||
imagefill($dest, 1, 1, $transparent);
|
||||
imagesavealpha($dest, true);
|
||||
|
||||
// Palette image with transparent color
|
||||
$png_palette = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyAgMAAABjUWAiAAAACVBMVEUAAAD/AAD///9nGWQeAAAAAXRSTlMAQObYZgAAAEFJREFUKM9jYBimIASZIxoagOAwhoaGInisQJ4DksJQJKWoPCAnNIQYHsgChBX4eMSbiddlqH5A9R+q39HCZWgDAFxFGyOrmguhAAAAAElFTkSuQmCCPHP'));
|
||||
|
||||
// 24 bit with transparent color
|
||||
$png_24 = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABupgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plDy5PCu2sAAAAASUVORK5CYII='));
|
||||
|
||||
// 32 bit with full alpha channel
|
||||
$png_full = imagecreatefromstring(base64_decode('iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAXklEQVRo3u3XMQrAIBBFwb3/pU2VwiJNIvjdzMD2PlBwqwAAAGajatxz9OGf5viA+KA3EXExXyKiYlqErIiIiBGSFLIyYmuMkO7Xy2MX4ovS/ONoH7Eh/m1nBwCASBe3VYeVaAy8PwAAAABJRU5ErkJggg=='));
|
||||
|
||||
imagecopy($dest, $png_palette, 0, 0, 0, 0, 50, 50);
|
||||
imagecopy($dest, $png_24, 50, 0, 0, 0, 50, 50);
|
||||
imagecopy($dest, $png_full, 100, 0, 0, 0, 50, 50);
|
||||
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/bug66005.png', $dest);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
The images are equal.
|
||||
==DONE==
|
||||
|
After Width: | Height: | Size: 430 B |
@@ -3,6 +3,9 @@ Bug #66590 (imagewebp() doesn't pad to even length)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
|
||||
die("skip test requires GD 2.2.0 or higher");
|
||||
}
|
||||
if (!function_exists('imagewebp')) die('skip WebP support not available');
|
||||
?>
|
||||
--FILE--
|
||||
|
||||
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Bug #67325 (imagetruecolortopalette: white is duplicated in palette)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.3', '<=')) {
|
||||
die("skip test requires newer than GD 2.2.3");
|
||||
}
|
||||
if (!(imagetypes() & IMG_JPG)) die('skip JPEG support not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$filename = __DIR__ . DIRECTORY_SEPARATOR . 'bug67325.jpeg';
|
||||
|
||||
$im = imagecreatefromjpeg($filename);
|
||||
imagetruecolortopalette($im, 0, 256);
|
||||
|
||||
$white = 0;
|
||||
for ($i = 0; $i < 256; $i++) {
|
||||
$components = imagecolorsforindex($im, $i);
|
||||
if ($components['red'] === 255 && $components['green'] === 255 && $components['blue'] === 255) {
|
||||
$white++;
|
||||
}
|
||||
}
|
||||
var_dump($white);
|
||||
|
||||
imagedestroy($im);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
int(0)
|
||||
===DONE===
|
||||
@@ -23,10 +23,19 @@ imagecolorallocate($image, 0, 0, 255); // first palette color = background
|
||||
$red = imagecolorallocate($image, 255, 0, 0);
|
||||
imagefill($image, 0, 0, $red);
|
||||
$cropped = imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 250]);
|
||||
var_dump(imagecolorat($cropped, 249, 249) === $red);
|
||||
var_dump(imagecolorsforindex($cropped, imagecolorat($cropped, 249, 249)));
|
||||
imagedestroy($image);
|
||||
imagedestroy($cropped);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
array(4) {
|
||||
["red"]=>
|
||||
int(255)
|
||||
["green"]=>
|
||||
int(0)
|
||||
["blue"]=>
|
||||
int(0)
|
||||
["alpha"]=>
|
||||
int(0)
|
||||
}
|
||||
@@ -3,6 +3,9 @@ Bug #70102 (imagecreatefromwebm() shifts colors)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
if (!GD_BUNDLED && version_compare(GD_VERSION, '2.2.0', '<')) {
|
||||
die("skip test requires GD 2.2.0 or higher");
|
||||
}
|
||||
if (!function_exists('imagewebp') || !function_exists('imagecreatefromwebp'))
|
||||
die('skip WebP support not available');
|
||||
?>
|
||||
|
||||
@@ -10,10 +10,9 @@ if (!(imagetypes() & IMG_PNG)) die('skip requires PNG support');
|
||||
$im = imagecreatetruecolor(100, 100);
|
||||
imagesetthickness($im, 5);
|
||||
imagearc($im, 50, 50, 90, 90, 0, 360, 0xffffff);
|
||||
ob_start();
|
||||
imagegd($im);
|
||||
$imagestring = ob_get_clean();
|
||||
echo md5($imagestring);
|
||||
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/bug72604.png', $im);
|
||||
?>
|
||||
--EXPECT--
|
||||
4f5080080a774efe4fc8d55cd4a5849c
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 700 B |
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #72913 (imagecopy() loses single-color transparency on palette images)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$base64 = 'iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAIAAACRXR/mAAAABnRSTlMAAAAAAABu'
|
||||
. 'pgeRAAAAVklEQVRYw+3UQQqAMBAEwf3/p9eTBxEPiWAmWMU8oGFJqgAAuOpzWTX3'
|
||||
. 'xQUti+uRJTZ9V5aY1bOTFZLV7yZr9zt6ibv/qPXfrMpsGipbIy7oqQ8AYJED1plD'
|
||||
. 'y5PCu2sAAAAASUVORK5CYII=';
|
||||
$src = imagecreatefromstring(base64_decode($base64));
|
||||
|
||||
$dst = imagecreate(50, 50);
|
||||
$transparent = imagecolorallocatealpha($dst, 255, 255, 255, 127);
|
||||
imagealphablending($dst, false);
|
||||
imagesavealpha($dst, true);
|
||||
|
||||
imagecopy($dst, $src, 0,0, 0,0, 50,50);
|
||||
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/bug72913.png', $dst);
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
The images are equal.
|
||||
==DONE==
|
||||
|
After Width: | Height: | Size: 147 B |
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Bug #73155 (imagegd2() writes wrong chunk sizes on boundaries)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$im = imagecreate(64, 64);
|
||||
imagecolorallocate($im, 0, 0, 0);
|
||||
|
||||
ob_start();
|
||||
imagegd2($im, null, 64, IMG_GD2_RAW);
|
||||
$buffer = ob_get_clean();
|
||||
|
||||
$header = unpack('@10/nchunk_size/nformat/nx_count/ny_count', $buffer);
|
||||
printf("chunk size: %d\n", $header['chunk_size']);
|
||||
printf("x chunk count: %d\n", $header['x_count']);
|
||||
printf("y chunk count: %d\n", $header['y_count']);
|
||||
printf("file size: %d\n", strlen($buffer));
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
chunk size: 64
|
||||
x chunk count: 1
|
||||
y chunk count: 1
|
||||
file size: 5145
|
||||
===DONE===
|
||||
@@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
Bug #73157 (imagegd2() ignores 3rd param if 4 are given)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$im = imagecreate(8, 8);
|
||||
imagecolorallocate($im, 0, 0, 0);
|
||||
|
||||
ob_start();
|
||||
imagegd2($im, null, 256, IMG_GD2_RAW);
|
||||
$buffer = ob_get_clean();
|
||||
|
||||
$header = unpack('@10/nchunk_size', $buffer);
|
||||
printf("chunk size: %d\n", $header['chunk_size']);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
chunk size: 256
|
||||
===DONE===
|
||||
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
Bug #73159 (imagegd2(): unrecognized formats may result in corrupted files)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$im = imagecreatetruecolor(10, 10);
|
||||
|
||||
ob_start();
|
||||
imagegd2($im, null, 128, 0);
|
||||
$buffer = ob_get_clean();
|
||||
|
||||
$header = unpack('@12/nformat', $buffer);
|
||||
printf("format: %d\n", $header['format']);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
format: 4
|
||||
===DONE===
|
||||
@@ -0,0 +1,18 @@
|
||||
--TEST--
|
||||
Bug #73161 (imagecreatefromgd2() may leak memory)
|
||||
--DESCRIPTION--
|
||||
We're testing for a memory leak that might not even show up with valgrind.
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die('skip gd extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
$im = imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . 'bug73161.gd2');
|
||||
var_dump($im);
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECTF--
|
||||
Warning: imagecreatefromgd2(): '%s' is not a valid GD2 file in %s on line %d
|
||||
bool(false)
|
||||
===DONE===
|
||||
@@ -59,3 +59,90 @@ function get_libxpm_version()
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that an in-memory image equals a PNG file.
|
||||
*
|
||||
* It checks for equal image sizes, and whether any pixels are different.
|
||||
* The textual result is printed, so the EXPECT section should contain the line
|
||||
* "The images are equal."
|
||||
*
|
||||
* If the PNG file does not exists, or the images are not equal, a diagnostic
|
||||
* message is printed, and the actual file is stored right beside the temporary
|
||||
* .php test file with the extension .out.png, to be able to manually inspect
|
||||
* the result.
|
||||
*
|
||||
* @param string $filename
|
||||
* @param resource $actual
|
||||
* @return void
|
||||
*/
|
||||
function test_image_equals_file($filename, $actual)
|
||||
{
|
||||
if (!file_exists($filename)) {
|
||||
echo "The expected image does not exist.\n";
|
||||
save_actual_image($actual);
|
||||
return;
|
||||
}
|
||||
$actual = test_to_truecolor($actual);
|
||||
$expected = imagecreatefrompng($filename);
|
||||
$expected = test_to_truecolor($expected);
|
||||
$exp_x = imagesx($expected);
|
||||
$exp_y = imagesy($expected);
|
||||
$act_x = imagesx($actual);
|
||||
$act_y = imagesy($actual);
|
||||
if ($exp_x != $act_x || $exp_y != $act_y) {
|
||||
echo "The image size differs: expected {$exp_x}x{$exp_y}, got {$act_x}x{$act_y}.\n";
|
||||
save_actual_image($actual);
|
||||
return;
|
||||
}
|
||||
$pixels_changed = 0;
|
||||
for ($y = 0; $y < $exp_y; $y++) {
|
||||
for ($x = 0; $x < $exp_x; $x ++) {
|
||||
$exp_c = imagecolorat($expected, $x, $y);
|
||||
$act_c = imagecolorat($actual, $x, $y);
|
||||
if ($exp_c != $act_c) {
|
||||
$pixels_changed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$pixels_changed) {
|
||||
echo "The images are equal.\n";
|
||||
} else {
|
||||
echo "The images differ in {$pixels_changed} pixels.\n";
|
||||
save_actual_image($actual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the truecolor version of an image.
|
||||
*
|
||||
* @param resource $image
|
||||
* @return resource
|
||||
*/
|
||||
function test_to_truecolor($image)
|
||||
{
|
||||
if (imageistruecolor($image)) {
|
||||
return $image;
|
||||
} else {
|
||||
$width = imagesx($image);
|
||||
$height = imagesy($image);
|
||||
$result = imagecreatetruecolor($width, $height);
|
||||
imagecopy($result, $image, 0,0, 0,0, $width, $height);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves an actual image to disk.
|
||||
*
|
||||
* The image is saved right beside the temporary .php test file with the
|
||||
* extension .out.png.
|
||||
*
|
||||
* @param resource $image
|
||||
* @return void
|
||||
*/
|
||||
function save_actual_image($image)
|
||||
{
|
||||
$pathinfo = pathinfo($_SERVER['SCRIPT_FILENAME']);
|
||||
$filename = "{$pathinfo['dirname']}/{$pathinfo['filename']}.out.png";
|
||||
imagepng($image, $filename);
|
||||
}
|
||||
@@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
|
||||
//create an arc with white color
|
||||
imagearc($image, 50, 50, 30, 30, 0, 180, $white);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagearc_basic.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
13149c3fd54a92a0d43cd5083a19b1d7
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 216 B |
@@ -17,13 +17,9 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
|
||||
//create an arc with white color
|
||||
imagearc($image, 50, 50, 30, 30, 0, 180);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagearc_error1.png', $image);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: imagearc() expects exactly 8 parameters, 7 given in %s on line %d
|
||||
c5b7013900f5466aebfc42499a7ec8ec
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 109 B |
@@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
|
||||
//create an arc with white color
|
||||
imagearc($image, 50, 50, 30, 30, 0, -90, $white);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagearc_variation1.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
fe662ebe7488057c43e38c5de43b1727
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 272 B |
@@ -17,12 +17,8 @@ $white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
|
||||
//create an arc with white color
|
||||
imagearc($image, 50, 50, 30, 30, -90, 0, $white);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagearc_variation2.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
8bd78aa775b5f29e7227eaeebaa84889
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 186 B |
@@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 255,255,255);
|
||||
|
||||
$result = imagechar($image, 1, 5, 5, 'C', $white);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagechar_basic.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
f0291252e7ac2fadda25e63287e6860c
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 128 B |
@@ -14,12 +14,8 @@ $white = imagecolorallocate($image, 255,255,255);
|
||||
|
||||
$result = imagecharup($image, 1, 5, 5, 'C', $white);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagecharup_basic.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
c65aad5d78f934dee2a844e7978eabd5
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 129 B |
@@ -20,14 +20,10 @@ $corA = imagecolorallocatealpha($img, 50, 100, 255, 50);
|
||||
$half = imagefilledarc ( $img, 75, 75, 70, 70, 0, 180, $cor, IMG_ARC_PIE );
|
||||
$half2 = imagefilledarc ( $img, 75, 75, 70, 70, 180, 360, $corA, IMG_ARC_PIE );
|
||||
|
||||
ob_start();
|
||||
imagegd($img);
|
||||
$imgsrc = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
var_dump(md5(base64_encode($imgsrc)));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagecolorallocatealpha_basic.png', $img);
|
||||
var_dump($corA);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(32) "0981ef94ee2209a8dccb59aa8ad07e18"
|
||||
The images are equal.
|
||||
int(842163455)
|
||||
|
After Width: | Height: | Size: 565 B |
@@ -23,13 +23,9 @@ $bg = imagecolorat($im, 0, 0);
|
||||
// Set the backgrund to be blue
|
||||
imagecolorset($im, $bg, 0, 0, 255);
|
||||
|
||||
// Get output and generate md5 hash
|
||||
ob_start();
|
||||
imagegd($im);
|
||||
$result_image = ob_get_contents();
|
||||
ob_end_clean();
|
||||
echo md5(base64_encode($result_image));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagecolorset_basic.png', $im);
|
||||
imagedestroy($im);
|
||||
?>
|
||||
--EXPECT--
|
||||
85e406abd0a975c97b3403cad5d078c9
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 99 B |
@@ -22,12 +22,8 @@ $gaussian = array(
|
||||
|
||||
imageconvolution($image, $gaussian, 16, 0);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imageconvolution_basic.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
20979b45f8772cdbd78262af4e332638
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 978 B |
@@ -11,12 +11,8 @@ Rafael Dohms <rdohms [at] gmail [dot] com>
|
||||
<?php
|
||||
$image = imagecreatetruecolor(180, 30);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imagecreatetruecolor_basic.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
da884f488a851e0267a316ad232aee86
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 95 B |
@@ -0,0 +1,85 @@
|
||||
--TEST--
|
||||
Testing imagecropauto()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if ( ! extension_loaded('gd') || !function_exists('imagecrop')) die( 'skip GD imagecropauto not present; skipping test' );
|
||||
if (GD_BUNDLED) die('skip requires external libgd');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
echo "TC IMG_CROP_DEFAULT\n";
|
||||
$im = imagecreatetruecolor(99, 99);
|
||||
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
||||
$im_crop = imagecropauto($im, IMG_CROP_DEFAULT);
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
echo "Palette IMG_CROP_DEFAULT\n";
|
||||
$im = imagecreate(99, 99);
|
||||
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
||||
$im_crop = imagecropauto($im, IMG_CROP_DEFAULT);
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
echo "TC IMG_CROP_SIDES\n";
|
||||
$im = imagecreatetruecolor(99, 99);
|
||||
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
||||
$im_crop = imagecropauto($im, IMG_CROP_SIDES);
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
echo "Palette IMG_CROP_SIDES\n";
|
||||
$im = imagecreate(99, 99);
|
||||
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
||||
$im_crop = imagecropauto($im, IMG_CROP_SIDES);
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
echo "TC IMG_CROP_BLACK\n";
|
||||
$im = imagecreatetruecolor(50, 50);
|
||||
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
||||
$im_crop = imagecropauto($im, IMG_CROP_BLACK);
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
echo "Palette IMG_CROP_BLACK\n";
|
||||
$im = imagecreate(50, 50);
|
||||
$bgd = imagecolorallocate($im, 0, 0, 0);
|
||||
$b = imagecolorallocate($im, 0, 0, 255);
|
||||
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
||||
$im_crop = imagecropauto($im, IMG_CROP_BLACK);
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
echo "IMG_CROP_THRESHOLD\n";
|
||||
$im = imagecreatefrompng(__DIR__ . "/logo_noise.png");
|
||||
$im_crop = imagecropauto($im, IMG_CROP_THRESHOLD, 0.1, 0x0);
|
||||
imagepng($im_crop, __DIR__ . "/crop_threshold.png");
|
||||
var_dump(imagesx($im_crop));
|
||||
var_dump(imagesy($im_crop));
|
||||
|
||||
@unlink(__DIR__ . "/crop_threshold.png");
|
||||
?>
|
||||
--EXPECT--
|
||||
TC IMG_CROP_DEFAULT
|
||||
int(99)
|
||||
int(99)
|
||||
Palette IMG_CROP_DEFAULT
|
||||
int(99)
|
||||
int(99)
|
||||
TC IMG_CROP_SIDES
|
||||
int(11)
|
||||
int(11)
|
||||
Palette IMG_CROP_SIDES
|
||||
int(11)
|
||||
int(11)
|
||||
TC IMG_CROP_BLACK
|
||||
int(11)
|
||||
int(11)
|
||||
Palette IMG_CROP_BLACK
|
||||
int(11)
|
||||
int(11)
|
||||
IMG_CROP_THRESHOLD
|
||||
int(240)
|
||||
int(134)
|
||||
@@ -3,6 +3,7 @@ Testing imagecropauto()
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if ( ! extension_loaded('gd') || !function_exists('imagecrop')) die( 'skip GD imagecropauto not present; skipping test' );
|
||||
if (!GD_BUNDLED) die('skip requires bundled libgd');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
@@ -16,12 +16,8 @@ $image = imagecreatetruecolor(400, 300);
|
||||
// Draw a white ellipse
|
||||
imageellipse($image, 200, 150, 300, 200, 16777215);
|
||||
|
||||
ob_start();
|
||||
imagegd($image);
|
||||
$img = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
echo md5(base64_encode($img));
|
||||
include_once __DIR__ . '/func.inc';
|
||||
test_image_equals_file(__DIR__ . '/imageellipse_basic.png', $image);
|
||||
?>
|
||||
--EXPECT--
|
||||
49c1544b012c3460c74cd04f1332d4ad
|
||||
The images are equal.
|
||||
|
After Width: | Height: | Size: 1.4 KiB |