Skip to content

Commit 1265c82

Browse files
committed
Merge branch 'PHP-7.0'
2 parents d0e3ce7 + 919562d commit 1265c82

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

ext/standard/file.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ PHP_FUNCTION(file_put_contents)
577577
php_stream_context *context = NULL;
578578
php_stream *srcstream = NULL;
579579
char mode[3] = "wb";
580-
char ret_ok = 1;
581580

582581
if (zend_parse_parameters(ZEND_NUM_ARGS(), "pz/|lr!", &filename, &filename_len, &data, &flags, &zcontext) == FAILURE) {
583582
return;
@@ -622,7 +621,7 @@ PHP_FUNCTION(file_put_contents)
622621
case IS_RESOURCE: {
623622
size_t len;
624623
if (php_stream_copy_to_stream_ex(srcstream, stream, PHP_STREAM_COPY_ALL, &len) != SUCCESS) {
625-
ret_ok = 0;
624+
numbytes = -1;
626625
} else {
627626
if (len > ZEND_LONG_MAX) {
628627
php_error_docref(NULL, E_WARNING, "content truncated from %zu to " ZEND_LONG_FMT " bytes", len, ZEND_LONG_MAX);
@@ -661,8 +660,8 @@ PHP_FUNCTION(file_put_contents)
661660
bytes_written = php_stream_write(stream, ZSTR_VAL(str), ZSTR_LEN(str));
662661
if (bytes_written != ZSTR_LEN(str)) {
663662
php_error_docref(NULL, E_WARNING, "Failed to write %zd bytes to %s", ZSTR_LEN(str), filename);
664-
ret_ok = 0;
665663
zend_string_release(str);
664+
numbytes = -1;
666665
break;
667666
}
668667
}
@@ -686,12 +685,12 @@ PHP_FUNCTION(file_put_contents)
686685
}
687686
}
688687
default:
689-
ret_ok = 0;
688+
numbytes = -1;
690689
break;
691690
}
692691
php_stream_close(stream);
693692

694-
if (!ret_ok) {
693+
if (numbytes < 0) {
695694
RETURN_FALSE;
696695
}
697696

0 commit comments

Comments
 (0)