Skip to content

Conversation

@nielsdos
Copy link
Member

We should destroy it when it's not IS_LONG, not when it's IS_LONG.

We should destroy it when it's not IS_LONG, not when it's IS_LONG.
} else if (Z_LVAL(retval) < 0) {
ret = -1;
}
zval_ptr_dtor(&retval);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t it leak if it’s not a LONG?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code path is only taken if it is a LONG. If it's not a long, the above code path is taken with the return FAILURE;. We therefore have to dtor the zval in the above path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my bad. I meant the case when it’s LONG — that was a typo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a LONG is not refcounted, so zval_ptr_dtor is a no-op on that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t know much about that, thanks!

@SakiTakamachi
Copy link
Member

SakiTakamachi commented Apr 16, 2025

Just in case: there’s a very similar piece of code in sqlite_driver.c, so that might need to be updated as well

Ah, no.
That one doesn’t return early, so there was no leak

@nielsdos nielsdos closed this in ce7304f Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants