Skip to content

Commit

Permalink
MySQL: Fixed binds free
Browse files Browse the repository at this point in the history
  • Loading branch information
Iswenzz committed Jul 14, 2022
1 parent 4e3c4d8 commit 5d03a04
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions src/net/mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void GScr_MySQL_Execute()
CHECK_PARAMS(0, "Usage: SQL_Execute()");
CHECK_MYSQL_INSTANCE();
CHECK_MYSQL_STMT();

// Bind params
if (mysql.bindsLength && mysql_stmt_bind_param(mysql.stmt, mysql.binds))
{
Expand Down Expand Up @@ -601,34 +601,30 @@ void MySQL_Free_Result()
{
mysql_free_result(mysql.resultStmt);
mysql.resultStmt = NULL;

// Free binds
if (mysql.binds)
{
for (int i = 0; i < mysql.bindsLength; i++)
free(mysql.binds[i].buffer);

free(mysql.binds);
mysql.binds = NULL;
mysql.bindsLength = 0;
}

// Free results binds
if (mysql.bindsResult)
{
for (int i = 0; i < mysql.bindsResultLength; i++)
free(mysql.bindsResult[i].buffer);

free(mysql.bindsResult);
mysql.bindsResult = NULL;
mysql.bindsResultLength = 0;
}
}
else if (mysql.result)
if (mysql.result)
{
mysql_free_result(mysql.result);
mysql.result = NULL;
}
if (mysql.binds)
{
for (int i = 0; i < mysql.bindsLength; i++)
free(mysql.binds[i].buffer);

free(mysql.binds);
mysql.binds = NULL;
mysql.bindsLength = 0;
}
if (mysql.bindsResult)
{
for (int i = 0; i < mysql.bindsResultLength; i++)
free(mysql.bindsResult[i].buffer);

free(mysql.bindsResult);
mysql.bindsResult = NULL;
mysql.bindsResultLength = 0;
}
}

void MySQL_Free()
Expand Down

0 comments on commit 5d03a04

Please sign in to comment.