Skip to content

Commit a4bce45

Browse files
committed
Merge remote-tracking branch 'origin/PHP-7.3' into PHP-7.3
2 parents 6f7a47d + 5297bed commit a4bce45

19 files changed

+147
-139
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
378378
ret_constant = NULL;
379379
} else {
380380
if (!zend_verify_const_access(c, scope)) {
381-
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));
381+
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
382+
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));
383+
}
382384
goto failure;
383385
}
384386
ret_constant = &c->value;

ext/date/php_date.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5275,21 +5275,14 @@ PHP_METHOD(DatePeriod, __wakeup)
52755275
/* {{{ date_period_read_property */
52765276
static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
52775277
{
5278-
zval *zv;
52795278
if (type != BP_VAR_IS && type != BP_VAR_R) {
52805279
zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
52815280
return &EG(uninitialized_zval);
52825281
}
52835282

52845283
Z_OBJPROP_P(object); /* build properties hash table */
52855284

5286-
zv = zend_std_read_property(object, member, type, cache_slot, rv);
5287-
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) {
5288-
/* defensive copy */
5289-
ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(zv));
5290-
}
5291-
5292-
return zv;
5285+
return zend_std_read_property(object, member, type, cache_slot, rv);
52935286
}
52945287
/* }}} */
52955288

ext/exif/exif.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,6 +3378,10 @@ static int exif_process_IFD_TAG(image_info_type *ImageInfo, char *dir_entry, cha
33783378
break;
33793379

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

ext/exif/tests/bug77564/bug77564.jpg

73 Bytes
Loading

ext/exif/tests/bug77564/bug77564.phpt

Lines changed: 18 additions & 0 deletions
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/mysqlnd/mysqlnd_ps.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
851851
MYSQLND_PACKET_ROW * row_packet;
852852
MYSQLND_CONN_DATA * conn = result->conn;
853853
const MYSQLND_RES_METADATA * const meta = result->meta;
854+
void *checkpoint;
854855

855856
DBG_ENTER("mysqlnd_stmt_fetch_row_unbuffered");
856857

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

877+
checkpoint = result->memory_pool->checkpoint;
878+
mysqlnd_mempool_save_state(result->memory_pool);
879+
876880
/*
877881
If we skip rows (stmt == NULL || stmt->result_bind == NULL) we have to
878882
result->unbuf->m.free_last_data() before it. The function returns always true.
@@ -895,6 +899,8 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
895899
conn->options->int_and_float_native,
896900
conn->stats))
897901
{
902+
mysqlnd_mempool_restore_state(result->memory_pool);
903+
result->memory_pool->checkpoint = checkpoint;
898904
DBG_RETURN(FAIL);
899905
}
900906

@@ -965,6 +971,9 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES * result, void * param, const unsi
965971
}
966972
}
967973

974+
mysqlnd_mempool_restore_state(result->memory_pool);
975+
result->memory_pool->checkpoint = checkpoint;
976+
968977
DBG_INF_FMT("ret=%s fetched_anything=%u", ret == PASS? "PASS":"FAIL", *fetched_anything);
969978
DBG_RETURN(ret);
970979
}

ext/opcache/ZendAccelerator.c

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,12 @@ static inline void accel_restart_enter(void)
236236
#ifdef ZEND_WIN32
237237
INCREMENT(restart_in);
238238
#else
239-
# ifdef _AIX
240-
static FLOCK_STRUCTURE(restart_in_progress, F_WRLCK, SEEK_SET, 2, 1);
241-
# else
242-
static const FLOCK_STRUCTURE(restart_in_progress, F_WRLCK, SEEK_SET, 2, 1);
243-
#endif
239+
struct flock restart_in_progress;
240+
241+
restart_in_progress.l_type = F_WRLCK;
242+
restart_in_progress.l_whence = SEEK_SET;
243+
restart_in_progress.l_start = 2;
244+
restart_in_progress.l_len = 1;
244245

245246
if (fcntl(lock_file, F_SETLK, &restart_in_progress) == -1) {
246247
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(+1): %s (%d)", strerror(errno), errno);
@@ -255,11 +256,12 @@ static inline void accel_restart_leave(void)
255256
ZCSG(restart_in_progress) = 0;
256257
DECREMENT(restart_in);
257258
#else
258-
# ifdef _AIX
259-
static FLOCK_STRUCTURE(restart_finished, F_UNLCK, SEEK_SET, 2, 1);
260-
# else
261-
static const FLOCK_STRUCTURE(restart_finished, F_UNLCK, SEEK_SET, 2, 1);
262-
# endif
259+
struct flock restart_finished;
260+
261+
restart_finished.l_type = F_UNLCK;
262+
restart_finished.l_whence = SEEK_SET;
263+
restart_finished.l_start = 2;
264+
restart_finished.l_len = 1;
263265

264266
ZCSG(restart_in_progress) = 0;
265267
if (fcntl(lock_file, F_SETLK, &restart_finished) == -1) {
@@ -272,7 +274,12 @@ static inline int accel_restart_is_active(void)
272274
{
273275
if (ZCSG(restart_in_progress)) {
274276
#ifndef ZEND_WIN32
275-
FLOCK_STRUCTURE(restart_check, F_WRLCK, SEEK_SET, 2, 1);
277+
struct flock restart_check;
278+
279+
restart_check.l_type = F_WRLCK;
280+
restart_check.l_whence = SEEK_SET;
281+
restart_check.l_start = 2;
282+
restart_check.l_len = 1;
276283

277284
if (fcntl(lock_file, F_GETLK, &restart_check) == -1) {
278285
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC: %s (%d)", strerror(errno), errno);
@@ -297,11 +304,12 @@ static inline int accel_activate_add(void)
297304
#ifdef ZEND_WIN32
298305
INCREMENT(mem_usage);
299306
#else
300-
# ifdef _AIX
301-
static FLOCK_STRUCTURE(mem_usage_lock, F_RDLCK, SEEK_SET, 1, 1);
302-
# else
303-
static const FLOCK_STRUCTURE(mem_usage_lock, F_RDLCK, SEEK_SET, 1, 1);
304-
# endif
307+
struct flock mem_usage_lock;
308+
309+
mem_usage_lock.l_type = F_RDLCK;
310+
mem_usage_lock.l_whence = SEEK_SET;
311+
mem_usage_lock.l_start = 1;
312+
mem_usage_lock.l_len = 1;
305313

306314
if (fcntl(lock_file, F_SETLK, &mem_usage_lock) == -1) {
307315
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC(+1): %s (%d)", strerror(errno), errno);
@@ -320,11 +328,12 @@ static inline void accel_deactivate_sub(void)
320328
ZCG(counted) = 0;
321329
}
322330
#else
323-
# ifdef _AIX
324-
static FLOCK_STRUCTURE(mem_usage_unlock, F_UNLCK, SEEK_SET, 1, 1);
325-
# else
326-
static const FLOCK_STRUCTURE(mem_usage_unlock, F_UNLCK, SEEK_SET, 1, 1);
327-
# endif
331+
struct flock mem_usage_unlock;
332+
333+
mem_usage_unlock.l_type = F_UNLCK;
334+
mem_usage_unlock.l_whence = SEEK_SET;
335+
mem_usage_unlock.l_start = 1;
336+
mem_usage_unlock.l_len = 1;
328337

329338
if (fcntl(lock_file, F_SETLK, &mem_usage_unlock) == -1) {
330339
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC(-1): %s (%d)", strerror(errno), errno);
@@ -337,11 +346,12 @@ static inline void accel_unlock_all(void)
337346
#ifdef ZEND_WIN32
338347
accel_deactivate_sub();
339348
#else
340-
# ifdef _AIX
341-
static FLOCK_STRUCTURE(mem_usage_unlock_all, F_UNLCK, SEEK_SET, 0, 0);
342-
# else
343-
static const FLOCK_STRUCTURE(mem_usage_unlock_all, F_UNLCK, SEEK_SET, 0, 0);
344-
# endif
349+
struct flock mem_usage_unlock_all;
350+
351+
mem_usage_unlock_all.l_type = F_UNLCK;
352+
mem_usage_unlock_all.l_whence = SEEK_SET;
353+
mem_usage_unlock_all.l_start = 0;
354+
mem_usage_unlock_all.l_len = 0;
345355

346356
if (fcntl(lock_file, F_SETLK, &mem_usage_unlock_all) == -1) {
347357
zend_accel_error(ACCEL_LOG_DEBUG, "UnlockAll: %s (%d)", strerror(errno), errno);
@@ -830,8 +840,12 @@ static inline int accel_is_inactive(void)
830840
return SUCCESS;
831841
}
832842
#else
833-
FLOCK_STRUCTURE(mem_usage_check, F_WRLCK, SEEK_SET, 1, 1);
843+
struct flock mem_usage_check;
834844

845+
mem_usage_check.l_type = F_WRLCK;
846+
mem_usage_check.l_whence = SEEK_SET;
847+
mem_usage_check.l_start = 1;
848+
mem_usage_check.l_len = 1;
835849
mem_usage_check.l_pid = -1;
836850
if (fcntl(lock_file, F_GETLK, &mem_usage_check) == -1) {
837851
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC: %s (%d)", strerror(errno), errno);

ext/opcache/ZendAccelerator.h

Lines changed: 0 additions & 13 deletions
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(HAVE_OPCACHE_FILE_CACHE) && defined(ZEND_WIN32)

ext/opcache/config.m4

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -341,63 +341,6 @@ int main() {
341341
msg=yes],[msg=no],[msg=no])
342342
AC_MSG_RESULT([$msg])
343343

344-
flock_type=unknown
345-
AC_MSG_CHECKING(for struct flock layout)
346-
347-
if test "$flock_type" = "unknown"; then
348-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
349-
#include <fcntl.h>
350-
struct flock lock = { 1, 2, 3, 4, 5, 6, 7 };
351-
int main() {
352-
if(lock.l_type == 1 && lock.l_whence == 2 && lock.l_start == 6 && lock.l_len== 7) {
353-
return 0;
354-
}
355-
return 1;
356-
}
357-
]])], [
358-
flock_type=aix64
359-
AC_DEFINE([HAVE_FLOCK_AIX64], [], [Struct flock is 64-bit AIX-type])
360-
], [])
361-
fi
362-
363-
if test "$flock_type" = "unknown"; then
364-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
365-
#include <fcntl.h>
366-
struct flock lock = { 1, 2, 3, 4, 5 };
367-
int main() {
368-
if(lock.l_type == 1 && lock.l_whence == 2 && lock.l_start == 3 && lock.l_len == 4) {
369-
return 0;
370-
}
371-
return 1;
372-
}
373-
]])], [
374-
flock_type=linux
375-
AC_DEFINE([HAVE_FLOCK_LINUX], [], [Struct flock is Linux-type])
376-
], [])
377-
fi
378-
379-
if test "$flock_type" = "unknown"; then
380-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
381-
#include <fcntl.h>
382-
struct flock lock = { 1, 2, 3, 4, 5 };
383-
int main() {
384-
if(lock.l_start == 1 && lock.l_len == 2 && lock.l_type == 4 && lock.l_whence == 5) {
385-
return 0;
386-
}
387-
return 1;
388-
}
389-
]])], [
390-
flock_type=bsd
391-
AC_DEFINE([HAVE_FLOCK_BSD], [], [Struct flock is BSD-type])
392-
], [])
393-
fi
394-
395-
AC_MSG_RESULT([$flock_type])
396-
397-
if test "$flock_type" = "unknown"; then
398-
AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])
399-
fi
400-
401344
PHP_NEW_EXTENSION(opcache,
402345
ZendAccelerator.c \
403346
zend_accelerator_blacklist.c \

ext/opcache/zend_shared_alloc.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,15 +375,15 @@ void zend_shared_alloc_safe_unlock(void)
375375
}
376376
}
377377

378-
#ifndef ZEND_WIN32
379-
/* name l_type l_whence l_start l_len */
380-
static FLOCK_STRUCTURE(mem_write_lock, F_WRLCK, SEEK_SET, 0, 1);
381-
static FLOCK_STRUCTURE(mem_write_unlock, F_UNLCK, SEEK_SET, 0, 1);
382-
#endif
383-
384378
void zend_shared_alloc_lock(void)
385379
{
386380
#ifndef ZEND_WIN32
381+
struct flock mem_write_lock;
382+
383+
mem_write_lock.l_type = F_WRLCK;
384+
mem_write_lock.l_whence = SEEK_SET;
385+
mem_write_lock.l_start = 0;
386+
mem_write_lock.l_len = 1;
387387

388388
#ifdef ZTS
389389
tsrm_mutex_lock(zts_lock);
@@ -414,6 +414,15 @@ void zend_shared_alloc_lock(void)
414414

415415
void zend_shared_alloc_unlock(void)
416416
{
417+
#ifndef ZEND_WIN32
418+
struct flock mem_write_unlock;
419+
420+
mem_write_unlock.l_type = F_UNLCK;
421+
mem_write_unlock.l_whence = SEEK_SET;
422+
mem_write_unlock.l_start = 0;
423+
mem_write_unlock.l_len = 1;
424+
#endif
425+
417426
ZCG(locked) = 0;
418427

419428
#ifndef ZEND_WIN32

ext/pcntl/pcntl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,12 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
12731273
break;
12741274
#endif
12751275
}
1276+
#if defined(SIGRTMIN) && defined(SIGRTMAX)
1277+
if (SIGRTMIN <= signo && signo <= SIGRTMAX) {
1278+
add_assoc_long_ex(user_siginfo, "pid", sizeof("pid")-1, siginfo->si_pid);
1279+
add_assoc_long_ex(user_siginfo, "uid", sizeof("uid")-1, siginfo->si_uid);
1280+
}
1281+
#endif
12761282
}
12771283
}
12781284
/* }}} */
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
pcntl_signal() context of realtime signal
3+
--SKIPIF--
4+
<?php if (!defined('SIGRTMIN')) die("skip realtime signal not supported"); ?>
5+
<?php if (!extension_loaded("pcntl")) print "skip"; ?>
6+
<?php if (!extension_loaded("posix")) die("skip posix extension not available"); ?>
7+
--FILE--
8+
<?php
9+
10+
pcntl_signal(SIGRTMIN, function ($signo, $siginfo) {
11+
printf("got realtime signal from %s, ruid:%s\n", $siginfo['pid'] ?? '', $siginfo['uid'] ?? '');
12+
});
13+
posix_kill(posix_getpid(), SIGRTMIN);
14+
pcntl_signal_dispatch();
15+
16+
echo "ok\n";
17+
?>
18+
--EXPECTF--
19+
%rgot realtime signal from \d+, ruid:\d+%r
20+
ok

ext/standard/http.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,6 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
190190
case IS_TRUE:
191191
smart_str_appendl(formstr, "1", sizeof("1")-1);
192192
break;
193-
case IS_DOUBLE:
194-
{
195-
char *ekey;
196-
size_t ekey_len;
197-
ekey_len = spprintf(&ekey, 0, "%.*G", (int) EG(precision), Z_DVAL_P(zdata));
198-
smart_str_appendl(formstr, ekey, ekey_len);
199-
efree(ekey);
200-
}
201-
break;
202193
default:
203194
{
204195
zend_string *ekey;

0 commit comments

Comments
 (0)