Skip to content

Commit

Permalink
Merge branch 'PHP-8.3'
Browse files Browse the repository at this point in the history
* PHP-8.3:
  Fix GH-12826: Weird pointers issue in nested loops
  Fix GH-12838: [SOAP] Temporary WSDL cache files not being deleted
  • Loading branch information
nielsdos committed Dec 1, 2023
2 parents 30acbba + b175ea4 commit 2af22ab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
30 changes: 30 additions & 0 deletions Zend/tests/gh12826.phpt
@@ -0,0 +1,30 @@
--TEST--
GH-12826 (Weird pointers issue in nested loops)
--FILE--
<?php
$test = array(
'a' => 1,
'b' => 2,
'c' => 3,
'd' => 4,
);

unset($test['a']);
unset($test['b']);

foreach($test as $k => &$v) { // Mind the reference!
echo "Pass $k : ";

foreach($test as $kk => $vv) {
echo $test[$kk];
if ($kk == $k) $test[$kk] = 0;
}

echo "\n";
}

unset($v);
?>
--EXPECT--
Pass c : 34
Pass d : 04
2 changes: 1 addition & 1 deletion Zend/zend_hash.c
Expand Up @@ -2407,7 +2407,7 @@ static zend_always_inline uint32_t zend_array_dup_elements(HashTable *source, Ha
idx++; p++;
}
} else {
target->nNumUsed = source->nNumOfElements;
target->nNumUsed = source->nNumUsed;
uint32_t iter_pos = zend_hash_iterators_lower_pos(target, idx);

while (p != end) {
Expand Down
4 changes: 3 additions & 1 deletion ext/soap/php_sdl.c
Expand Up @@ -2393,7 +2393,9 @@ static void add_sdl_to_cache(const char *fn, const char *uri, time_t t, sdlPtr s
/* Make sure that incomplete files (e.g. due to disk space issues, see bug #66150) are not utilised. */
if (valid_file) {
/* This is allowed to fail, this means that another process was raced to create the file. */
(void) VCWD_RENAME(ZSTR_VAL(temp_file_path), fn);
if (VCWD_RENAME(ZSTR_VAL(temp_file_path), fn) < 0) {
VCWD_UNLINK(ZSTR_VAL(temp_file_path));
}
}

smart_str_free(&buf);
Expand Down

0 comments on commit 2af22ab

Please sign in to comment.