diff options
author | Andrey Hristov <andrey@php.net> | 2010-12-06 13:50:51 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2010-12-06 13:50:51 +0000 |
commit | 03fd10c479d7e45d8b622f0dafba616b19cc21b4 (patch) | |
tree | f2bb12b5ece96ff52b234e30d49a8de39591a369 /ext/mysqlnd/mysqlnd.c | |
parent | 75eeee8f243b97712a54f431d895f537db88a164 (diff) | |
download | php-git-03fd10c479d7e45d8b622f0dafba616b19cc21b4.tar.gz |
don't crash if the API is used incorrectly
Diffstat (limited to 'ext/mysqlnd/mysqlnd.c')
-rw-r--r-- | ext/mysqlnd/mysqlnd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 6aa94e2e00..d4ccd00346 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -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); |