mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
don't crash if the API is used incorrectly
This commit is contained in:
parent
75eeee8f24
commit
03fd10c479
1 changed files with 6 additions and 2 deletions
|
@ -1971,15 +1971,19 @@ MYSQLND_METHOD(mysqlnd_conn, change_user)(MYSQLND * const conn,
|
|||
}
|
||||
}
|
||||
if (ret == PASS) {
|
||||
char * tmp = NULL;
|
||||
/* if we get conn->user as parameter and then we first free it, then estrndup it, we will crash */
|
||||
tmp = mnd_pestrndup(user, user_len, conn->persistent);
|
||||
if (conn->user) {
|
||||
mnd_pefree(conn->user, conn->persistent);
|
||||
}
|
||||
conn->user = mnd_pestrndup(user, user_len, conn->persistent);
|
||||
conn->user = tmp;
|
||||
|
||||
tmp = mnd_pestrdup(passwd, conn->persistent);
|
||||
if (conn->passwd) {
|
||||
mnd_pefree(conn->passwd, conn->persistent);
|
||||
}
|
||||
conn->passwd = mnd_pestrdup(passwd, conn->persistent);
|
||||
conn->passwd = tmp;
|
||||
|
||||
if (conn->last_message) {
|
||||
mnd_pefree(conn->last_message, conn->persistent);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue