-
Notifications
You must be signed in to change notification settings - Fork 70
fix(agent): PDO database_object_handle zval to zend_object #1138
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
base: feat/php-8.5
Are you sure you want to change the base?
Conversation
|
b34ede3 to
c91f83b
Compare
cc1fe50 to
828fb8e
Compare
| #include "nr_datastore_instance.h" | ||
|
|
||
| #if ZEND_MODULE_API_NO >= ZEND_8_5_X_API_NO | ||
| #define PHP_PDO_DBH zend_object* |
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.
Suggest naming this NR_PHP_PDO_DBH to clarify that it's our define vs a PHP define.
| */ | ||
| extern pdo_dbh_t* nr_php_pdo_get_database_object(zval* dbh TSRMLS_DC); | ||
|
|
||
| /* Purpose : Returns the pdo_dbh_t struct that is contained in the object store |
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.
| /* Purpose : Returns the pdo_dbh_t struct that is contained in the object store | |
| /* | |
| * Purpose : Returns the pdo_dbh_t struct that is contained in the object store |
| #else | ||
| dbh = &pdo_stmt->database_object_handle; | ||
| #endif | ||
| dup = nr_php_pdo_duplicate(dbh TSRMLS_CC); |
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.
It needs a null check somewhere along the path for dbh.
dbh is passed into nr_php_pdo_duplicate, which for 8.5 passes to nr_php_pdo_get_database_object_from_zend_object which dereferences here.
|
|
||
| pdo_dbh_t* nr_php_pdo_get_database_object_from_zend_object( | ||
| zend_object* dbh TSRMLS_DC) { | ||
| if (nr_php_class_entry_instanceof_class(dbh->ce, "PDO" TSRMLS_CC)) { |
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.
NULL check before dereferencing dbh.
| } | ||
|
|
||
| #if ZEND_MODULE_API_NO >= ZEND_8_5_X_API_NO | ||
| return (zval*)nr_hashmap_index_get(NRTXNGLOBAL(pdo_link_options), |
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.
NULL check before derefencing dbh.
| extern int __attribute__((weak)) php_pdo_parse_data_source( | ||
| const char* data_source, | ||
| zend_ulong data_source_len, | ||
| struct pdo_data_src_parser* parsed, | ||
| int nparams); |
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.
Just formatting?
| static inline pdo_dbh_t* | ||
| nr_php_pdo_get_database_object_internal_from_zend_object( | ||
| zend_object* dbh TSRMLS_DC) { | ||
| return php_pdo_dbh_fetch_inner(dbh); | ||
| } | ||
|
|
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.
Needs a NULL check for dbh since php_pdo_dbh_fetch_inner doesn't check.
|
Great solution to address the issue! Could you please update the description with why the change was needed? |
828fb8e to
6017038
Compare
bebd53f to
6017038
Compare
6017038 to
23d9a34
Compare
No description provided.