Skip to content

Commit d373d13

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 5c23370 + 10cbf9f commit d373d13

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+365
-177
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ environment:
1616
PHP_BUILD_CACHE_BASE_DIR: c:\build-cache
1717
PHP_BUILD_OBJ_DIR: c:\obj
1818
PHP_BUILD_CACHE_SDK_DIR: c:\build-cache\sdk
19-
PHP_BUILD_SDK_BRANCH: php-sdk-2.2.0beta1
19+
PHP_BUILD_SDK_BRANCH: php-sdk-2.2.0beta3
2020
PHP_BUILD_CRT: vc15
2121
# ext and env setup for tests
2222
#MYSQL_TEST_PASSWD: Password12!

Zend/zend_constants.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
368368
ret_constant = NULL;
369369
} else {
370370
if (!zend_verify_const_access(c, scope)) {
371-
zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
371+
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
372+
zend_throw_error(NULL, "Cannot access %s const %s::%s", zend_visibility_string(Z_ACCESS_FLAGS(c->value)), ZSTR_VAL(class_name), ZSTR_VAL(constant_name));
373+
}
372374
goto failure;
373375
}
374376
ret_constant = &c->value;

ext/date/php_date.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -5218,21 +5218,14 @@ PHP_METHOD(DatePeriod, __wakeup)
52185218
/* {{{ date_period_read_property */
52195219
static zval *date_period_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv)
52205220
{
5221-
zval *zv;
52225221
if (type != BP_VAR_IS && type != BP_VAR_R) {
52235222
zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
52245223
return &EG(uninitialized_zval);
52255224
}
52265225

52275226
object->handlers->get_properties(object); /* build properties hash table */
52285227

5229-
zv = zend_std_read_property(object, name, type, cache_slot, rv);
5230-
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) {
5231-
/* defensive copy */
5232-
ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(Z_OBJ_P(zv)));
5233-
}
5234-
5235-
return zv;
5228+
return zend_std_read_property(object, name, type, cache_slot, rv);
52365229
}
52375230
/* }}} */
52385231

ext/exif/exif.c

+4
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,10 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
33773377
break;
33783378

33793379
case TAG_USERCOMMENT:
3380+
EFREE_IF(ImageInfo->UserComment);
3381+
ImageInfo->UserComment = NULL;
3382+
EFREE_IF(ImageInfo->UserCommentEncoding);
3383+
ImageInfo->UserCommentEncoding = NULL;
33803384
ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(ImageInfo->UserCommentEncoding), value_ptr, byte_count);
33813385
break;
33823386

ext/exif/tests/bug77564/bug77564.jpg

73 Bytes
Loading

ext/exif/tests/bug77564/bug77564.phpt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Bug 77564 (Memory leak in exif_process_IFD_TAG)
3+
--SKIPIF--
4+
<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5+
--FILE--
6+
<?php
7+
var_dump(exif_read_data(dirname(__FILE__) . '/bug77564.jpg'));
8+
?>
9+
DONE
10+
--EXPECTF--
11+
12+
Warning: exif_read_data(bug77564.jpg): Illegal IFD offset in %sbug77564.php on line %d
13+
14+
Warning: exif_read_data(bug77564.jpg): File structure corrupted in %sbug77564.php on line %d
15+
16+
Warning: exif_read_data(bug77564.jpg): Invalid JPEG file in %sbug77564.php on line %d
17+
bool(false)
18+
DONE

ext/ffi/ffi.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -1117,10 +1117,16 @@ static void zend_ffi_cdata_write_dim(zend_object *obj, zval *offset, zval *value
11171117
{
11181118
zend_ffi_cdata *cdata = (zend_ffi_cdata*)obj;
11191119
zend_ffi_type *type = ZEND_FFI_TYPE(cdata->type);
1120-
zend_long dim = zval_get_long(offset);
1120+
zend_long dim;
11211121
void *ptr;
11221122
zend_ffi_flags is_const;
11231123

1124+
if (offset == NULL) {
1125+
zend_throw_error(zend_ffi_exception_ce, "Cannot add next element to object of type FFI\\CData");
1126+
return;
1127+
}
1128+
1129+
dim = zval_get_long(offset);
11241130
if (EXPECTED(type->kind == ZEND_FFI_TYPE_ARRAY)) {
11251131
if (UNEXPECTED((zend_ulong)(dim) >= (zend_ulong)type->array.length)
11261132
&& (UNEXPECTED(dim < 0) || UNEXPECTED(type->array.length != 0))) {
@@ -5257,7 +5263,7 @@ void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t n
52575263
zend_ffi_parser_error("wrong type of bit field '%.*s' at line %d", name ? name_len : sizeof("<anonymous>")-1, name ? name : "<anonymous>", FFI_G(line));
52585264
}
52595265

5260-
if (bits->kind == ZEND_FFI_VAL_INT32 || ZEND_FFI_VAL_INT64) {
5266+
if (bits->kind == ZEND_FFI_VAL_INT32 || bits->kind == ZEND_FFI_VAL_INT64) {
52615267
if (bits->i64 < 0) {
52625268
zend_ffi_cleanup_dcl(field_dcl);
52635269
zend_ffi_parser_error("negative width in bit-field '%.*s' at line %d", name ? name_len : sizeof("<anonymous>")-1, name ? name : "<anonymous>", FFI_G(line));
@@ -5271,7 +5277,7 @@ void zend_ffi_add_bit_field(zend_ffi_dcl *struct_dcl, const char *name, size_t n
52715277
zend_ffi_cleanup_dcl(field_dcl);
52725278
zend_ffi_parser_error("width of '%.*s' exceeds its type at line %d", name ? name_len : sizeof("<anonymous>")-1, name ? name : "<anonymous>", FFI_G(line));
52735279
}
5274-
} else if (ZEND_FFI_VAL_UINT32 || ZEND_FFI_VAL_UINT64) {
5280+
} else if (bits->kind == ZEND_FFI_VAL_UINT32 || bits->kind == ZEND_FFI_VAL_UINT64) {
52755281
if (bits->u64 == 0) {
52765282
zend_ffi_cleanup_dcl(field_dcl);
52775283
if (name) {

ext/ffi/tests/042.phpt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
FFI 042: Next array element
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--INI--
6+
ffi.enable=1
7+
--FILE--
8+
<?php
9+
$a = FFI::new("uint8_t[8]");
10+
$a[] = 0;
11+
?>
12+
--EXPECTF--
13+
Fatal error: Uncaught FFI\Exception: Cannot add next element to object of type FFI\CData in %s:3
14+
Stack trace:
15+
#0 {main}
16+
thrown in %s on line 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
--TEST--
2+
mb_str*() - unknown encoding
3+
--CREDITS--
4+
Jachim Coudenys <[email protected]>
5+
User Group: PHP-WVL & PHPGent #PHPTestFest
6+
--SKIPIF--
7+
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
8+
--FILE--
9+
<?php
10+
mb_chr(1, 'UTF-0');
11+
mb_convert_case('coudenys', MB_CASE_UPPER, 'UTF-0');
12+
mb_convert_encoding('coudenys', 'UTF-8', 'UTF-0');
13+
mb_convert_kana('coudenys', 'KV', 'UTF-0');
14+
mb_decode_numericentity('coudenys', 'KV', 'UTF-0');
15+
mb_ord('coudenys', 'UTF-0');
16+
mb_strcut('coudenys', 0, 4, 'UTF-0');
17+
mb_strimwidth('coudenys', 0, 4, '', 'UTF-0');
18+
mb_stripos('coudenys', 'cou', 0, 'UTF-0');
19+
mb_stristr('coudenys', 'cou', false, 'UTF-0');
20+
mb_strlen('coudenys', 'UTF-0');
21+
mb_strpos('coudenys', 'cou', 0, 'UTF-0');
22+
mb_strrchr('coudenys', 'cou', false, 'UTF-0');
23+
mb_strrichr('coudenys', 'cou', false, 'UTF-0');
24+
mb_strripos('coudenys', 'cou', 0, 'UTF-0');
25+
mb_strrpos('coudenys', 'cou', 0, 'UTF-0');
26+
mb_strstr('coudenys', 'cou', false, 'UTF-0');
27+
mb_strtolower('coudenys', 'UTF-0');
28+
mb_strtoupper('coudenys', 'UTF-0');
29+
mb_strwidth('coudenys', 'UTF-0');
30+
mb_substr('coudenys', 0, null, 'UTF-0');
31+
mb_substr_count('coudenys', 'c', 'UTF-0');
32+
?>
33+
--EXPECTF--
34+
Warning: mb_chr(): Unknown encoding "UTF-0" in %s on line %d
35+
36+
Warning: mb_convert_case(): Unknown encoding "UTF-0" in %s on line %d
37+
38+
Warning: mb_convert_encoding(): Illegal character encoding specified in %s on line %d
39+
40+
Warning: mb_convert_kana(): Unknown encoding "UTF-0" in %s on line %d
41+
42+
Warning: mb_decode_numericentity(): Unknown encoding "UTF-0" in %s on line %d
43+
44+
Warning: mb_ord(): Unknown encoding "UTF-0" in %s on line %d
45+
46+
Warning: mb_strcut(): Unknown encoding "UTF-0" in %s on line %d
47+
48+
Warning: mb_strimwidth(): Unknown encoding "UTF-0" in %s on line %d
49+
50+
Warning: mb_stripos(): Unknown encoding "UTF-0" in %s on line %d
51+
52+
Warning: mb_stristr(): Unknown encoding "UTF-0" in %s on line %d
53+
54+
Warning: mb_strlen(): Unknown encoding "UTF-0" in %s on line %d
55+
56+
Warning: mb_strpos(): Unknown encoding "UTF-0" in %s on line %d
57+
58+
Warning: mb_strrchr(): Unknown encoding "UTF-0" in %s on line %d
59+
60+
Warning: mb_strrichr(): Unknown encoding "UTF-0" in %s on line %d
61+
62+
Warning: mb_strripos(): Unknown encoding "UTF-0" in %s on line %d
63+
64+
Warning: mb_strrpos(): Unknown encoding "UTF-0" in %s on line %d
65+
66+
Warning: mb_strstr(): Unknown encoding "UTF-0" in %s on line %d
67+
68+
Warning: mb_strtolower(): Unknown encoding "UTF-0" in %s on line %d
69+
70+
Warning: mb_strtoupper(): Unknown encoding "UTF-0" in %s on line %d
71+
72+
Warning: mb_strwidth(): Unknown encoding "UTF-0" in %s on line %d
73+
74+
Warning: mb_substr(): Unknown encoding "UTF-0" in %s on line %d
75+
76+
Warning: mb_substr_count(): Unknown encoding "UTF-0" in %s on line %d
77+

ext/mysqlnd/mysqlnd_ps.c

+9
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
797797
MYSQLND_PACKET_ROW * row_packet;
798798
MYSQLND_CONN_DATA * conn = result->conn;
799799
const MYSQLND_RES_METADATA * const meta = result->meta;
800+
void *checkpoint;
800801

801802
DBG_ENTER("mysqlnd_stmt_fetch_row_unbuffered");
802803

@@ -819,6 +820,9 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
819820
/* Let the row packet fill our buffer and skip additional malloc + memcpy */
820821
row_packet->skip_extraction = stmt && stmt->result_bind? FALSE:TRUE;
821822

823+
checkpoint = result->memory_pool->checkpoint;
824+
mysqlnd_mempool_save_state(result->memory_pool);
825+
822826
/*
823827
If we skip rows (stmt == NULL || stmt->result_bind == NULL) we have to
824828
result->unbuf->m.free_last_data() before it. The function returns always true.
@@ -841,6 +845,8 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
841845
conn->options->int_and_float_native,
842846
conn->stats))
843847
{
848+
mysqlnd_mempool_restore_state(result->memory_pool);
849+
result->memory_pool->checkpoint = checkpoint;
844850
DBG_RETURN(FAIL);
845851
}
846852

@@ -900,6 +906,9 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
900906
}
901907
}
902908

909+
mysqlnd_mempool_restore_state(result->memory_pool);
910+
result->memory_pool->checkpoint = checkpoint;
911+
903912
DBG_INF_FMT("ret=%s fetched_anything=%u", ret == PASS? "PASS":"FAIL", *fetched_anything);
904913
DBG_RETURN(ret);
905914
}

ext/opcache/ZendAccelerator.c

+41-27
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ static inline void accel_restart_enter(void)
238238
#ifdef ZEND_WIN32
239239
INCREMENT(restart_in);
240240
#else
241-
# ifdef _AIX
242-
static FLOCK_STRUCTURE(restart_in_progress, F_WRLCK, SEEK_SET, 2, 1);
243-
# else
244-
static const FLOCK_STRUCTURE(restart_in_progress, F_WRLCK, SEEK_SET, 2, 1);
245-
#endif
241+
struct flock restart_in_progress;
242+
243+
restart_in_progress.l_type = F_WRLCK;
244+
restart_in_progress.l_whence = SEEK_SET;
245+
restart_in_progress.l_start = 2;
246+
restart_in_progress.l_len = 1;
246247

247248
if (fcntl(lock_file, F_SETLK, &restart_in_progress) == -1) {
248249
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(+1): %s (%d)", strerror(errno), errno);
@@ -257,11 +258,12 @@ static inline void accel_restart_leave(void)
257258
ZCSG(restart_in_progress) = 0;
258259
DECREMENT(restart_in);
259260
#else
260-
# ifdef _AIX
261-
static FLOCK_STRUCTURE(restart_finished, F_UNLCK, SEEK_SET, 2, 1);
262-
# else
263-
static const FLOCK_STRUCTURE(restart_finished, F_UNLCK, SEEK_SET, 2, 1);
264-
# endif
261+
struct flock restart_finished;
262+
263+
restart_finished.l_type = F_UNLCK;
264+
restart_finished.l_whence = SEEK_SET;
265+
restart_finished.l_start = 2;
266+
restart_finished.l_len = 1;
265267

266268
ZCSG(restart_in_progress) = 0;
267269
if (fcntl(lock_file, F_SETLK, &restart_finished) == -1) {
@@ -274,7 +276,12 @@ static inline int accel_restart_is_active(void)
274276
{
275277
if (ZCSG(restart_in_progress)) {
276278
#ifndef ZEND_WIN32
277-
FLOCK_STRUCTURE(restart_check, F_WRLCK, SEEK_SET, 2, 1);
279+
struct flock restart_check;
280+
281+
restart_check.l_type = F_WRLCK;
282+
restart_check.l_whence = SEEK_SET;
283+
restart_check.l_start = 2;
284+
restart_check.l_len = 1;
278285

279286
if (fcntl(lock_file, F_GETLK, &restart_check) == -1) {
280287
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC: %s (%d)", strerror(errno), errno);
@@ -299,11 +306,12 @@ static inline int accel_activate_add(void)
299306
#ifdef ZEND_WIN32
300307
INCREMENT(mem_usage);
301308
#else
302-
# ifdef _AIX
303-
static FLOCK_STRUCTURE(mem_usage_lock, F_RDLCK, SEEK_SET, 1, 1);
304-
# else
305-
static const FLOCK_STRUCTURE(mem_usage_lock, F_RDLCK, SEEK_SET, 1, 1);
306-
# endif
309+
struct flock mem_usage_lock;
310+
311+
mem_usage_lock.l_type = F_RDLCK;
312+
mem_usage_lock.l_whence = SEEK_SET;
313+
mem_usage_lock.l_start = 1;
314+
mem_usage_lock.l_len = 1;
307315

308316
if (fcntl(lock_file, F_SETLK, &mem_usage_lock) == -1) {
309317
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC(+1): %s (%d)", strerror(errno), errno);
@@ -322,11 +330,12 @@ static inline void accel_deactivate_sub(void)
322330
ZCG(counted) = 0;
323331
}
324332
#else
325-
# ifdef _AIX
326-
static FLOCK_STRUCTURE(mem_usage_unlock, F_UNLCK, SEEK_SET, 1, 1);
327-
# else
328-
static const FLOCK_STRUCTURE(mem_usage_unlock, F_UNLCK, SEEK_SET, 1, 1);
329-
# endif
333+
struct flock mem_usage_unlock;
334+
335+
mem_usage_unlock.l_type = F_UNLCK;
336+
mem_usage_unlock.l_whence = SEEK_SET;
337+
mem_usage_unlock.l_start = 1;
338+
mem_usage_unlock.l_len = 1;
330339

331340
if (fcntl(lock_file, F_SETLK, &mem_usage_unlock) == -1) {
332341
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC(-1): %s (%d)", strerror(errno), errno);
@@ -339,11 +348,12 @@ static inline void accel_unlock_all(void)
339348
#ifdef ZEND_WIN32
340349
accel_deactivate_sub();
341350
#else
342-
# ifdef _AIX
343-
static FLOCK_STRUCTURE(mem_usage_unlock_all, F_UNLCK, SEEK_SET, 0, 0);
344-
# else
345-
static const FLOCK_STRUCTURE(mem_usage_unlock_all, F_UNLCK, SEEK_SET, 0, 0);
346-
# endif
351+
struct flock mem_usage_unlock_all;
352+
353+
mem_usage_unlock_all.l_type = F_UNLCK;
354+
mem_usage_unlock_all.l_whence = SEEK_SET;
355+
mem_usage_unlock_all.l_start = 0;
356+
mem_usage_unlock_all.l_len = 0;
347357

348358
if (fcntl(lock_file, F_SETLK, &mem_usage_unlock_all) == -1) {
349359
zend_accel_error(ACCEL_LOG_DEBUG, "UnlockAll: %s (%d)", strerror(errno), errno);
@@ -812,8 +822,12 @@ static inline int accel_is_inactive(void)
812822
return SUCCESS;
813823
}
814824
#else
815-
FLOCK_STRUCTURE(mem_usage_check, F_WRLCK, SEEK_SET, 1, 1);
825+
struct flock mem_usage_check;
816826

827+
mem_usage_check.l_type = F_WRLCK;
828+
mem_usage_check.l_whence = SEEK_SET;
829+
mem_usage_check.l_start = 1;
830+
mem_usage_check.l_len = 1;
817831
mem_usage_check.l_pid = -1;
818832
if (fcntl(lock_file, F_GETLK, &mem_usage_check) == -1) {
819833
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC: %s (%d)", strerror(errno), errno);

ext/opcache/ZendAccelerator.h

-13
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,6 @@
8989
/*** file locking ***/
9090
#ifndef ZEND_WIN32
9191
extern int lock_file;
92-
93-
# if defined(HAVE_FLOCK_AIX64)
94-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
95-
struct flock name = {type, whence, 0, 0, 0, start, len }
96-
# elif defined(HAVE_FLOCK_BSD)
97-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
98-
struct flock name = {start, len, -1, type, whence}
99-
# elif defined(HAVE_FLOCK_LINUX)
100-
# define FLOCK_STRUCTURE(name, type, whence, start, len) \
101-
struct flock name = {type, whence, start, len}
102-
# else
103-
# error "Don't know how to define struct flock"
104-
# endif
10592
#endif
10693

10794
#if defined(ZEND_WIN32)

0 commit comments

Comments
 (0)