Skip to content
Permalink
Browse files Browse the repository at this point in the history
Merge pull request #45 from hannob/master
Fix use after free error.
  • Loading branch information
mbeijen committed Nov 22, 2015
2 parents 90a5ab5 + 2e1cbd0 commit cf0aa77
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dbdimp.c
Expand Up @@ -2085,10 +2085,6 @@ static int my_login(pTHX_ SV* dbh, imp_dbh_t *imp_dbh)
}
result = mysql_dr_connect(dbh, imp_dbh->pmysql, mysql_socket, host, port, user,
password, dbname, imp_dbh) ? TRUE : FALSE;
if (fresh && !result) {
/* Prevent leaks, but do not free in case of a reconnect. See #97625 */
Safefree(imp_dbh->pmysql);
}
return result;
}

Expand Down Expand Up @@ -2142,9 +2138,12 @@ int dbd_db_login(SV* dbh, imp_dbh_t* imp_dbh, char* dbname, char* user,

if (!my_login(aTHX_ dbh, imp_dbh))
{
if(imp_dbh->pmysql)
if(imp_dbh->pmysql) {
do_error(dbh, mysql_errno(imp_dbh->pmysql),
mysql_error(imp_dbh->pmysql) ,mysql_sqlstate(imp_dbh->pmysql));
Safefree(imp_dbh->pmysql);

}
return FALSE;
}

Expand Down

0 comments on commit cf0aa77

Please sign in to comment.