-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/pdo_firebird: Fixed GH-18276 - persistent connection - "zend_mm_heap corrupted" with setAttribute()
#18280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e175d97 to
bd8ad0e
Compare
bd8ad0e to
1c25919
Compare
|
Ah, the cause appears to be a mixture of persistent and non-persistent memory. It's too late now so I'll fix it tomorrow. |
ext/pdo_firebird/firebird_driver.c
Outdated
| if (H->date_format) { | ||
| efree(H->date_format); | ||
| pefree(H->date_format, dbh->is_persistent); | ||
| H->date_format = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're freeing the entire structure anyway below, you don't need to set the pointers for these 3 fields to NULL.
| if (H->date_format) { | ||
| efree(H->date_format); | ||
| pefree(H->date_format, dbh->is_persistent); | ||
| H->date_format = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with these being set to NULL because technically we could bail out if the pestrdup below fails.
ext/pdo_firebird/firebird_driver.c
Outdated
| H->date_format = NULL; | ||
| } | ||
| spprintf(&H->date_format, 0, "%s", ZSTR_VAL(str)); | ||
| H->date_format = pestrdup(ZSTR_VAL(str), dbh->is_persistent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we know the length, you should use pestrndup instead and pass in ZSTR_LEN(str) as well (same below).
| PDO::ATTR_PERSISTENT => true, | ||
| ], | ||
| ); | ||
| // Avoid interned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
str_repeat is special cased in the SCCP optimization pass if you have a constant number as a second argument, and so you'll still get an interned string here.
You need to do this: str_repeat('my string', random_int(1, 1));
|
@nielsdos |
fixes #18276
The structure has changed slightly on master, so I don’t plan to apply the change the third commit to master.
I’ll follow up with a separate PR for changes targeting master.