Skip to content

Commit 56dba3f

Browse files
committed
Merge remote-tracking branch 'origin/PHP-7.2' into PHP-7.2
2 parents 83d2bc9 + 07877c4 commit 56dba3f

18 files changed

+138
-139
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
@@ -341,7 +341,9 @@ ZEND_API zval *zend_get_constant_ex(zend_string *cname, zend_class_entry *scope,
341341
ret_constant = NULL;
342342
} else {
343343
if (!zend_verify_const_access(c, scope)) {
344-
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));
344+
if ((flags & ZEND_FETCH_CLASS_SILENT) == 0) {
345+
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));
346+
}
345347
goto failure;
346348
}
347349
ret_constant = &c->value;

ext/date/php_date.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -5278,21 +5278,14 @@ PHP_METHOD(DatePeriod, __wakeup)
52785278
/* {{{ date_period_read_property */
52795279
static zval *date_period_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv)
52805280
{
5281-
zval *zv;
52825281
if (type != BP_VAR_IS && type != BP_VAR_R) {
52835282
zend_throw_error(NULL, "Retrieval of DatePeriod properties for modification is unsupported");
52845283
return &EG(uninitialized_zval);
52855284
}
52865285

52875286
Z_OBJPROP_P(object); /* build properties hash table */
52885287

5289-
zv = std_object_handlers.read_property(object, member, type, cache_slot, rv);
5290-
if (Z_TYPE_P(zv) == IS_OBJECT && Z_OBJ_HANDLER_P(zv, clone_obj)) {
5291-
/* defensive copy */
5292-
ZVAL_OBJ(zv, Z_OBJ_HANDLER_P(zv, clone_obj)(zv));
5293-
}
5294-
5295-
return zv;
5288+
return std_object_handlers.read_property(object, member, type, cache_slot, rv);
52965289
}
52975290
/* }}} */
52985291

ext/exif/exif.c

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

34073407
case TAG_USERCOMMENT:
3408+
EFREE_IF(ImageInfo->UserComment);
3409+
ImageInfo->UserComment = NULL;
3410+
EFREE_IF(ImageInfo->UserCommentEncoding);
3411+
ImageInfo->UserCommentEncoding = NULL;
34083412
ImageInfo->UserCommentLength = exif_process_user_comment(ImageInfo, &(ImageInfo->UserComment), &(ImageInfo->UserCommentEncoding), value_ptr, byte_count);
34093413
break;
34103414

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/opcache/ZendAccelerator.c

+41-27
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,12 @@ static inline void accel_restart_enter(void)
230230
#ifdef ZEND_WIN32
231231
INCREMENT(restart_in);
232232
#else
233-
# ifdef _AIX
234-
static FLOCK_STRUCTURE(restart_in_progress, F_WRLCK, SEEK_SET, 2, 1);
235-
# else
236-
static const FLOCK_STRUCTURE(restart_in_progress, F_WRLCK, SEEK_SET, 2, 1);
237-
#endif
233+
struct flock restart_in_progress;
234+
235+
restart_in_progress.l_type = F_WRLCK;
236+
restart_in_progress.l_whence = SEEK_SET;
237+
restart_in_progress.l_start = 2;
238+
restart_in_progress.l_len = 1;
238239

239240
if (fcntl(lock_file, F_SETLK, &restart_in_progress) == -1) {
240241
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC(+1): %s (%d)", strerror(errno), errno);
@@ -249,11 +250,12 @@ static inline void accel_restart_leave(void)
249250
ZCSG(restart_in_progress) = 0;
250251
DECREMENT(restart_in);
251252
#else
252-
# ifdef _AIX
253-
static FLOCK_STRUCTURE(restart_finished, F_UNLCK, SEEK_SET, 2, 1);
254-
# else
255-
static const FLOCK_STRUCTURE(restart_finished, F_UNLCK, SEEK_SET, 2, 1);
256-
# endif
253+
struct flock restart_finished;
254+
255+
restart_finished.l_type = F_UNLCK;
256+
restart_finished.l_whence = SEEK_SET;
257+
restart_finished.l_start = 2;
258+
restart_finished.l_len = 1;
257259

258260
ZCSG(restart_in_progress) = 0;
259261
if (fcntl(lock_file, F_SETLK, &restart_finished) == -1) {
@@ -266,7 +268,12 @@ static inline int accel_restart_is_active(void)
266268
{
267269
if (ZCSG(restart_in_progress)) {
268270
#ifndef ZEND_WIN32
269-
FLOCK_STRUCTURE(restart_check, F_WRLCK, SEEK_SET, 2, 1);
271+
struct flock restart_check;
272+
273+
restart_check.l_type = F_WRLCK;
274+
restart_check.l_whence = SEEK_SET;
275+
restart_check.l_start = 2;
276+
restart_check.l_len = 1;
270277

271278
if (fcntl(lock_file, F_GETLK, &restart_check) == -1) {
272279
zend_accel_error(ACCEL_LOG_DEBUG, "RestartC: %s (%d)", strerror(errno), errno);
@@ -291,11 +298,12 @@ static inline int accel_activate_add(void)
291298
#ifdef ZEND_WIN32
292299
INCREMENT(mem_usage);
293300
#else
294-
# ifdef _AIX
295-
static FLOCK_STRUCTURE(mem_usage_lock, F_RDLCK, SEEK_SET, 1, 1);
296-
# else
297-
static const FLOCK_STRUCTURE(mem_usage_lock, F_RDLCK, SEEK_SET, 1, 1);
298-
# endif
301+
struct flock mem_usage_lock;
302+
303+
mem_usage_lock.l_type = F_RDLCK;
304+
mem_usage_lock.l_whence = SEEK_SET;
305+
mem_usage_lock.l_start = 1;
306+
mem_usage_lock.l_len = 1;
299307

300308
if (fcntl(lock_file, F_SETLK, &mem_usage_lock) == -1) {
301309
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC(+1): %s (%d)", strerror(errno), errno);
@@ -314,11 +322,12 @@ static inline void accel_deactivate_sub(void)
314322
ZCG(counted) = 0;
315323
}
316324
#else
317-
# ifdef _AIX
318-
static FLOCK_STRUCTURE(mem_usage_unlock, F_UNLCK, SEEK_SET, 1, 1);
319-
# else
320-
static const FLOCK_STRUCTURE(mem_usage_unlock, F_UNLCK, SEEK_SET, 1, 1);
321-
# endif
325+
struct flock mem_usage_unlock;
326+
327+
mem_usage_unlock.l_type = F_UNLCK;
328+
mem_usage_unlock.l_whence = SEEK_SET;
329+
mem_usage_unlock.l_start = 1;
330+
mem_usage_unlock.l_len = 1;
322331

323332
if (fcntl(lock_file, F_SETLK, &mem_usage_unlock) == -1) {
324333
zend_accel_error(ACCEL_LOG_DEBUG, "UpdateC(-1): %s (%d)", strerror(errno), errno);
@@ -331,11 +340,12 @@ static inline void accel_unlock_all(void)
331340
#ifdef ZEND_WIN32
332341
accel_deactivate_sub();
333342
#else
334-
# ifdef _AIX
335-
static FLOCK_STRUCTURE(mem_usage_unlock_all, F_UNLCK, SEEK_SET, 0, 0);
336-
# else
337-
static const FLOCK_STRUCTURE(mem_usage_unlock_all, F_UNLCK, SEEK_SET, 0, 0);
338-
# endif
343+
struct flock mem_usage_unlock_all;
344+
345+
mem_usage_unlock_all.l_type = F_UNLCK;
346+
mem_usage_unlock_all.l_whence = SEEK_SET;
347+
mem_usage_unlock_all.l_start = 0;
348+
mem_usage_unlock_all.l_len = 0;
339349

340350
if (fcntl(lock_file, F_SETLK, &mem_usage_unlock_all) == -1) {
341351
zend_accel_error(ACCEL_LOG_DEBUG, "UnlockAll: %s (%d)", strerror(errno), errno);
@@ -730,8 +740,12 @@ static inline int accel_is_inactive(void)
730740
return SUCCESS;
731741
}
732742
#else
733-
FLOCK_STRUCTURE(mem_usage_check, F_WRLCK, SEEK_SET, 1, 1);
743+
struct flock mem_usage_check;
734744

745+
mem_usage_check.l_type = F_WRLCK;
746+
mem_usage_check.l_whence = SEEK_SET;
747+
mem_usage_check.l_start = 1;
748+
mem_usage_check.l_len = 1;
735749
mem_usage_check.l_pid = -1;
736750
if (fcntl(lock_file, F_GETLK, &mem_usage_check) == -1) {
737751
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(HAVE_OPCACHE_FILE_CACHE) && defined(ZEND_WIN32)

ext/opcache/config.m4

-57
Original file line numberDiff line numberDiff line change
@@ -343,63 +343,6 @@ int main() {
343343
msg=yes,msg=no,msg=no)
344344
AC_MSG_RESULT([$msg])
345345

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

ext/opcache/zend_shared_alloc.c

+15-6
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,15 @@ void zend_shared_alloc_safe_unlock(void)
371371
}
372372
}
373373

374-
#ifndef ZEND_WIN32
375-
/* name l_type l_whence l_start l_len */
376-
static FLOCK_STRUCTURE(mem_write_lock, F_WRLCK, SEEK_SET, 0, 1);
377-
static FLOCK_STRUCTURE(mem_write_unlock, F_UNLCK, SEEK_SET, 0, 1);
378-
#endif
379-
380374
void zend_shared_alloc_lock(void)
381375
{
382376
#ifndef ZEND_WIN32
377+
struct flock mem_write_lock;
378+
379+
mem_write_lock.l_type = F_WRLCK;
380+
mem_write_lock.l_whence = SEEK_SET;
381+
mem_write_lock.l_start = 0;
382+
mem_write_lock.l_len = 1;
383383

384384
#ifdef ZTS
385385
tsrm_mutex_lock(zts_lock);
@@ -410,6 +410,15 @@ void zend_shared_alloc_lock(void)
410410

411411
void zend_shared_alloc_unlock(void)
412412
{
413+
#ifndef ZEND_WIN32
414+
struct flock mem_write_unlock;
415+
416+
mem_write_unlock.l_type = F_UNLCK;
417+
mem_write_unlock.l_whence = SEEK_SET;
418+
mem_write_unlock.l_start = 0;
419+
mem_write_unlock.l_len = 1;
420+
#endif
421+
413422
ZCG(locked) = 0;
414423

415424
#ifndef ZEND_WIN32

ext/pcntl/pcntl.c

+6
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,12 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
12761276
break;
12771277
#endif
12781278
}
1279+
#if defined(SIGRTMIN) && defined(SIGRTMAX)
1280+
if (SIGRTMIN <= signo && signo <= SIGRTMAX) {
1281+
add_assoc_long_ex(user_siginfo, "pid", sizeof("pid")-1, siginfo->si_pid);
1282+
add_assoc_long_ex(user_siginfo, "uid", sizeof("uid")-1, siginfo->si_uid);
1283+
}
1284+
#endif
12791285
}
12801286
}
12811287
/* }}} */
+20
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

-9
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,6 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr,
192192
case IS_TRUE:
193193
smart_str_appendl(formstr, "1", sizeof("1")-1);
194194
break;
195-
case IS_DOUBLE:
196-
{
197-
char *ekey;
198-
size_t ekey_len;
199-
ekey_len = spprintf(&ekey, 0, "%.*G", (int) EG(precision), Z_DVAL_P(zdata));
200-
smart_str_appendl(formstr, ekey, ekey_len);
201-
efree(ekey);
202-
}
203-
break;
204195
default:
205196
{
206197
zend_string *ekey;

ext/standard/tests/general_functions/bug72920.phpt

+4-7
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ class Foo {
66
private const C1 = "a";
77
}
88

9-
try {
10-
var_dump(constant('Foo::C1'));
11-
} catch (Error $e) {
12-
var_dump($e->getMessage());
13-
}
14-
--EXPECT--
15-
string(35) "Cannot access private const Foo::C1"
9+
var_dump(constant('Foo::C1'));
10+
--EXPECTF--
11+
Warning: constant(): Couldn't find constant Foo::C1 in %s on line %d
12+
NULL
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #77608: http_build_query doesn't encode "+" in a float number
3+
--FILE--
4+
<?php
5+
6+
$a = ["x" => 1E+14, "y" => "1E+14"];
7+
echo http_build_query($a);
8+
9+
?>
10+
--EXPECT--
11+
x=1.0E%2B14&y=1E%2B14

tests/classes/constants_visibility_002.phpt

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,4 @@ constant('A::protectedConst');
2121
string(14) "protectedConst"
2222
string(14) "protectedConst"
2323

24-
Fatal error: Uncaught Error: Cannot access protected const A::protectedConst in %s:14
25-
Stack trace:
26-
#0 %s(14): constant('A::protectedCon...')
27-
#1 {main}
28-
thrown in %s on line 14
24+
Warning: constant(): Couldn't find constant A::protectedConst in %s on line %d

0 commit comments

Comments
 (0)