mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted" with setAttribute() (#18280) Closes #18280 Fixes #18276
This commit is contained in:
4
NEWS
4
NEWS
@@ -39,6 +39,10 @@ PHP NEWS
|
||||
(nielsdos)
|
||||
. Fix potential leaks when writing to BIO fails. (nielsdos)
|
||||
|
||||
- PDO Firebird:
|
||||
. Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted"
|
||||
with setAttribute() (SakiTakamachi).
|
||||
|
||||
- SPL:
|
||||
. Fixed bug GH-18322 (SplObjectStorage debug handler mismanages memory).
|
||||
(nielsdos)
|
||||
|
||||
@@ -599,13 +599,13 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
|
||||
}
|
||||
|
||||
if (H->date_format) {
|
||||
efree(H->date_format);
|
||||
pefree(H->date_format, dbh->is_persistent);
|
||||
}
|
||||
if (H->time_format) {
|
||||
efree(H->time_format);
|
||||
pefree(H->time_format, dbh->is_persistent);
|
||||
}
|
||||
if (H->timestamp_format) {
|
||||
efree(H->timestamp_format);
|
||||
pefree(H->timestamp_format, dbh->is_persistent);
|
||||
}
|
||||
|
||||
if (H->einfo.errmsg) {
|
||||
@@ -1091,9 +1091,10 @@ static bool pdo_firebird_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val
|
||||
return false;
|
||||
}
|
||||
if (H->date_format) {
|
||||
efree(H->date_format);
|
||||
pefree(H->date_format, dbh->is_persistent);
|
||||
H->date_format = NULL;
|
||||
}
|
||||
spprintf(&H->date_format, 0, "%s", ZSTR_VAL(str));
|
||||
H->date_format = pestrndup(ZSTR_VAL(str), ZSTR_LEN(str),dbh->is_persistent);
|
||||
zend_string_release_ex(str, 0);
|
||||
}
|
||||
return true;
|
||||
@@ -1105,9 +1106,10 @@ static bool pdo_firebird_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val
|
||||
return false;
|
||||
}
|
||||
if (H->time_format) {
|
||||
efree(H->time_format);
|
||||
pefree(H->time_format, dbh->is_persistent);
|
||||
H->time_format = NULL;
|
||||
}
|
||||
spprintf(&H->time_format, 0, "%s", ZSTR_VAL(str));
|
||||
H->time_format = pestrndup(ZSTR_VAL(str), ZSTR_LEN(str),dbh->is_persistent);
|
||||
zend_string_release_ex(str, 0);
|
||||
}
|
||||
return true;
|
||||
@@ -1119,9 +1121,10 @@ static bool pdo_firebird_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val
|
||||
return false;
|
||||
}
|
||||
if (H->timestamp_format) {
|
||||
efree(H->timestamp_format);
|
||||
pefree(H->timestamp_format, dbh->is_persistent);
|
||||
H->timestamp_format = NULL;
|
||||
}
|
||||
spprintf(&H->timestamp_format, 0, "%s", ZSTR_VAL(str));
|
||||
H->timestamp_format = pestrndup(ZSTR_VAL(str), ZSTR_LEN(str),dbh->is_persistent);
|
||||
zend_string_release_ex(str, 0);
|
||||
}
|
||||
return true;
|
||||
|
||||
35
ext/pdo_firebird/tests/gh18276.phpt
Normal file
35
ext/pdo_firebird/tests/gh18276.phpt
Normal file
@@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
GH-18276 (persistent connection - setAttribute(Pdo\Firebird::ATTR_DATE_FORMAT, ..) results in "zend_mm_heap corrupted")
|
||||
--EXTENSIONS--
|
||||
pdo_firebird
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--XLEAK--
|
||||
A bug in firebird causes a memory leak when calling `isc_attach_database()`.
|
||||
See https://github.com/FirebirdSQL/firebird/issues/7849
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require("testdb.inc");
|
||||
unset($dbh);
|
||||
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$dbh = new PDO(
|
||||
PDO_FIREBIRD_TEST_DSN,
|
||||
PDO_FIREBIRD_TEST_USER,
|
||||
PDO_FIREBIRD_TEST_PASS,
|
||||
[
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
],
|
||||
);
|
||||
// Avoid interned
|
||||
$dbh->setAttribute(PDO::FB_ATTR_DATE_FORMAT, str_repeat('Y----m----d', random_int(1, 1)));
|
||||
$dbh->setAttribute(PDO::FB_ATTR_TIME_FORMAT, str_repeat('H::::i::::s', random_int(1, 1)));
|
||||
$dbh->setAttribute(PDO::FB_ATTR_TIMESTAMP_FORMAT, str_repeat('Y----m----d....H::::i::::s', random_int(1, 1)));
|
||||
unset($dbh);
|
||||
}
|
||||
|
||||
echo 'done!';
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
Reference in New Issue
Block a user