Skip to content

Fixed bug #66124 #532

Closed
wants to merge 2 commits into from

3 participants

@nikic nikic and 2 others commented on an outdated diff Nov 20, 2013
ext/mysqlnd/mysqlnd_ps_codec.c
@@ -585,7 +585,8 @@ void _mysqlnd_init_ps_fetch_subsystem()
*/
if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
- convert_to_double_ex(&tmp_data);
+ //convert_to_double_ex(&tmp_data);
+ convert_to_long_ex(&tmp_data);
if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
@nikic
nikic added a note Nov 20, 2013

Accessing DVAL after casting to long? That can't be right...

@sskaje
sskaje added a note Nov 20, 2013

You're right nikic, I put my focus on my problem but forgetting to get everything right, sorry for that.
but the convert to double issue really caused my problem, maybe I should get another temporary zval to make old code working as well

@mapthegod
mapthegod added a note Nov 20, 2013
@mapthegod
mapthegod added a note Nov 20, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sskaje
sskaje commented Nov 20, 2013

@nikic would you please review the latest commit?

@nikic nikic commented on the diff Nov 21, 2013
ext/mysqlnd/mysqlnd_ps_codec.c
if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
stmt->send_types_to_server = resend_types_next_time = 1;
}
+ zval_dtor(tmp_data);
@nikic
nikic added a note Nov 21, 2013

You created the zval with MAKE_STD_ZVAL but destroy with zval_dtor, that will leak the container. You're probably looking for something like this:

zval tmp_data;
ZVAL_ZVAL(&tmp_data, (copies && copies[i]) ? copies[i]: stmt->param_bind[i].zv, 1, 0);
convert_to_double(&tmp_data);
// ...
zval_dtor(&tmp_data);

That's the semi-standard approach to performing a cast without touching the zval. The ZVAL_ZVAL is the same as ZVAL_COPY_VALUE+zval_copy_ctor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@sskaje sskaje closed this Nov 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.