Skip to content

Commit 9602db3

Browse files
committed
Fix open_mode for SplTempFileObject
open_mode was initialized to "wb", but the length set only to 1. The effect of this was that the stream is opened using "wb", but we only report "w". Fix the length to report the actually used open_mode.
1 parent 3b3f6de commit 9602db3

4 files changed

+4
-4
lines changed

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ PHP_METHOD(SplTempFileObject, __construct)
21142114
}
21152115
intern->file_name = file_name;
21162116
intern->u.file.open_mode = "wb";
2117-
intern->u.file.open_mode_len = 1;
2117+
intern->u.file.open_mode_len = sizeof("wb")-1;
21182118

21192119
zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling);
21202120
if (spl_filesystem_file_open(intern, 0, 0) == SUCCESS) {

ext/spl/tests/SplTempFileObject_constructor_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object(SplTempFileObject)#1 (5) {
1111
["fileName":"SplFileInfo":private]=>
1212
string(10) "php://temp"
1313
["openMode":"SplFileObject":private]=>
14-
string(1) "w"
14+
string(2) "wb"
1515
["delimiter":"SplFileObject":private]=>
1616
string(1) ","
1717
["enclosure":"SplFileObject":private]=>

ext/spl/tests/SplTempFileObject_constructor_maxmemory_basic.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object(SplTempFileObject)#1 (5) {
1111
["fileName":"SplFileInfo":private]=>
1212
string(25) "php://temp/maxmemory:1024"
1313
["openMode":"SplFileObject":private]=>
14-
string(1) "w"
14+
string(2) "wb"
1515
["delimiter":"SplFileObject":private]=>
1616
string(1) ","
1717
["enclosure":"SplFileObject":private]=>

ext/spl/tests/SplTempFileObject_constructor_memory_lt1_variation.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object(SplTempFileObject)#1 (5) {
1111
["fileName":"SplFileInfo":private]=>
1212
string(12) "php://memory"
1313
["openMode":"SplFileObject":private]=>
14-
string(1) "w"
14+
string(2) "wb"
1515
["delimiter":"SplFileObject":private]=>
1616
string(1) ","
1717
["enclosure":"SplFileObject":private]=>

0 commit comments

Comments
 (0)