Skip to content

Commit

Permalink
don't crash if the API is used incorrectly
Browse files Browse the repository at this point in the history
  • Loading branch information
faizshukri committed Dec 6, 2010
1 parent 75eeee8 commit 03fd10c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ext/mysqlnd/mysqlnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 03fd10c

Please sign in to comment.