1
0
mirror of https://github.com/php/php-src.git synced 2026-04-19 14:01:01 +02:00

don't crash if the API is used incorrectly

This commit is contained in:
Andrey Hristov
2010-12-06 13:50:51 +00:00
parent 3722811395
commit e183ea0495

View File

@@ -1994,15 +1994,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);