Skip to content

ext/mysqlnd: Fix close_on_server#21765

Open
kamil-tekiela wants to merge 2 commits intophp:masterfrom
kamil-tekiela:Fix-close_on_server
Open

ext/mysqlnd: Fix close_on_server#21765
kamil-tekiela wants to merge 2 commits intophp:masterfrom
kamil-tekiela:Fix-close_on_server

Conversation

@kamil-tekiela
Copy link
Copy Markdown
Member

No description provided.

Comment thread ext/mysqlnd/mysqlnd_ps.c
if (ret == FAIL) {
COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
DBG_RETURN(FAIL);
/* Don't return early - continue with cleanup to prevent memory leaks */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we do not return early here, won’t this end up returning PASS?

It introduces a bit of code duplication, but how about adding the cleanup logic here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this better now?

Copy link
Copy Markdown
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

I'm no longer involved, so can't meaningfully review this without spending time on it.
From a quick look it seems logical but who knows for sure without spending more time on it.

Comment thread ext/mysqlnd/mysqlnd_ps.c
break;
}
if (statistic != STAT_LAST) {
MYSQLND_INC_CONN_STATISTIC(conn->stats, statistic);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No knowledge of mysqlnd, but is it correct for MYSQLND_INC_CONN_STATISTIC to run in this case? Otherwise, a goto might help.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it is correct. It doesn't matter much because it's only a statistic. Even if the prepared statement isn't freed on the server, everything related to it will be gone in PHP so updating the statistics makes sense. There is no way, IMHO, that you can call close again.

@bukka
Copy link
Copy Markdown
Member

bukka commented Apr 17, 2026

I think this should be testable using fake server.

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.

5 participants