-
Notifications
You must be signed in to change notification settings - Fork 7.9k
ext/pdo_sqlite: PDO::sqliteCreateCollection return type strenghtening. #18799
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
Is supposed to be Pdo_Sqlite::createCollation but behavior differs in regard of return type checks.
7661ce5
to
4494e12
Compare
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.
MSTM, but this needs an UPGRADING entry as this is a BC technically
if (Z_LVAL(retval) > 0) { | ||
ret = 1; | ||
} else if (Z_LVAL(retval) < 0) { | ||
ret = -1; | ||
} |
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.
Follow-up: Could we not use ZEND_NORMALIZE_BOOL
here rather than doing it "manually"
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.
not a bad idea !
@@ -385,14 +385,14 @@ static int php_sqlite_collation_callback(void *context, int string1_len, const v | |||
zend_type_error("%s(): Return value of the collation callback must be of type int, %s returned", | |||
ZSTR_VAL(func_name), zend_zval_value_name(&retval)); | |||
zend_string_release(func_name); | |||
zval_ptr_dtor(&retval); | |||
return FAILURE; | |||
ret = FAILURE; |
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.
This change in this file is wrong, why did you change this?
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.
In particular, you're accessing the zval as if it were a long below, but that's not the case. This means you're either interpreting garbage bytes or uninit memory.
zend_type_error("%s(): Return value of the collation callback must be of type int, %s returned", | ||
ZSTR_VAL(func_name), zend_zval_value_name(&retval)); | ||
zend_string_release(func_name); | ||
ret = FAILURE; |
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.
Similarly, this is also wrong
Is supposed to be Pdo_Sqlite::createCollation alias but behavior differs in regard of return type checks.