Skip to content

Commit 5324865

Browse files
committed
Merge branch 'PHP-7.1' of git.php.net:/php-src into PHP-7.1
* 'PHP-7.1' of git.php.net:/php-src: Flush stderr on win32 in cli_log_message Fixed bug #73154
2 parents b4459af + a5027d4 commit 5324865

File tree

13 files changed

+31
-119
lines changed

13 files changed

+31
-119
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ PHP NEWS
5757
parameter). (Bruce Weirdan)
5858
. Fixed bug #70213 (Unserialize context shared on double class lookup).
5959
(Taoguang Chen)
60+
. Fixed bug #73154 (serialize object with __sleep function crash). (Nikita)
6061
. Add subject to mail log. (tomsommer)
6162

6263
- Zlib

ext/session/tests/bug66481-win32.phpt

Lines changed: 0 additions & 17 deletions
This file was deleted.

ext/session/tests/bug66481.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Bug #66481: Calls to session_name() segfault when session.name is null.
44
session.name=
55
--SKIPIF--
66
<?php include('skipif.inc'); ?>
7-
<?php if(substr(PHP_OS, 0, 3) == "WIN") die("skip Not for Windows"); ?>
87
--FILE--
98
<?php
109

ext/session/tests/rfc1867_invalid_settings-win.phpt

Lines changed: 0 additions & 19 deletions
This file was deleted.

ext/session/tests/rfc1867_invalid_settings.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ error_log=
66
--SKIPIF--
77
<?php
88
include('skipif.inc');
9-
if(substr(PHP_OS, 0, 3) == "WIN")
10-
die("skip Not for Windows");
119
?>
1210
--FILE--
1311
<?php

ext/session/tests/rfc1867_invalid_settings_2-win.phpt

Lines changed: 0 additions & 19 deletions
This file was deleted.

ext/session/tests/rfc1867_invalid_settings_2.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ error_log=
66
--SKIPIF--
77
<?php
88
include('skipif.inc');
9-
if(substr(PHP_OS, 0, 3) == "WIN")
10-
die("skip Not for Windows");
119
?>
1210
--FILE--
1311
<?php

ext/soap/tests/bugs/bug31422-win.phpt

Lines changed: 0 additions & 47 deletions
This file was deleted.

ext/soap/tests/bugs/bug31422.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
Bug #31422 (No Error-Logging on SoapServer-Side)
33
--SKIPIF--
44
<?php
5-
if (substr(PHP_OS, 0, 3) == 'WIN') {
6-
die('skip not valid for windows');
7-
}
85
require_once('skipif.inc');
96
?>
107
--INI--
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #73154: serialize object with __sleep function crash
3+
--FILE--
4+
<?php
5+
class a {
6+
public $a;
7+
public function __sleep() {
8+
$this->a=null;
9+
return array();
10+
}
11+
}
12+
$s = 'a:1:{i:0;O:1:"a":1:{s:1:"a";R:2;}}';
13+
var_dump(serialize(unserialize($s)));
14+
?>
15+
--EXPECT--
16+
string(22) "a:1:{i:0;O:1:"a":0:{}}"

ext/standard/var.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -860,9 +860,6 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
860860
return;
861861

862862
case IS_OBJECT: {
863-
zval retval;
864-
zval fname;
865-
int res;
866863
zend_class_entry *ce = Z_OBJCE_P(struc);
867864

868865
if (ce->serialize != NULL) {
@@ -891,32 +888,39 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, php_serialize_
891888
}
892889

893890
if (ce != PHP_IC_ENTRY && zend_hash_str_exists(&ce->function_table, "__sleep", sizeof("__sleep")-1)) {
891+
zval fname, tmp, retval;
892+
int res;
893+
894+
ZVAL_COPY(&tmp, struc);
894895
ZVAL_STRINGL(&fname, "__sleep", sizeof("__sleep") - 1);
895896
BG(serialize_lock)++;
896-
res = call_user_function_ex(CG(function_table), struc, &fname, &retval, 0, 0, 1, NULL);
897+
res = call_user_function_ex(CG(function_table), &tmp, &fname, &retval, 0, 0, 1, NULL);
897898
BG(serialize_lock)--;
898899
zval_dtor(&fname);
899900

900901
if (EG(exception)) {
901902
zval_ptr_dtor(&retval);
903+
zval_ptr_dtor(&tmp);
902904
return;
903905
}
904906

905907
if (res == SUCCESS) {
906908
if (Z_TYPE(retval) != IS_UNDEF) {
907909
if (HASH_OF(&retval)) {
908-
php_var_serialize_class(buf, struc, &retval, var_hash);
910+
php_var_serialize_class(buf, &tmp, &retval, var_hash);
909911
} else {
910912
php_error_docref(NULL, E_NOTICE, "__sleep should return an array only containing the names of instance-variables to serialize");
911913
/* we should still add element even if it's not OK,
912914
* since we already wrote the length of the array before */
913915
smart_str_appendl(buf,"N;", 2);
914916
}
915-
zval_ptr_dtor(&retval);
916917
}
918+
zval_ptr_dtor(&retval);
919+
zval_ptr_dtor(&tmp);
917920
return;
918921
}
919922
zval_ptr_dtor(&retval);
923+
zval_ptr_dtor(&tmp);
920924
}
921925

922926
/* fall-through */

main/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,11 +1165,9 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
11651165
if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi")) &&
11661166
PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR
11671167
) {
1168-
#ifdef PHP_WIN32
11691168
fprintf(stderr, "%s: %s in %s on line %u\n", error_type_str, buffer, error_filename, error_lineno);
1169+
#ifdef PHP_WIN32
11701170
fflush(stderr);
1171-
#else
1172-
fprintf(stderr, "%s: %s in %s on line %u\n", error_type_str, buffer, error_filename, error_lineno);
11731171
#endif
11741172
} else {
11751173
php_printf("%s\n%s: %s in %s on line %d\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));

sapi/cli/php_cli.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,9 @@ static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */
380380
static void sapi_cli_log_message(char *message, int syslog_type_int) /* {{{ */
381381
{
382382
fprintf(stderr, "%s\n", message);
383+
#ifdef PHP_WIN32
384+
fflush(stderr);
385+
#endif
383386
}
384387
/* }}} */
385388

0 commit comments

Comments
 (0)