You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
Valgrind fixes:
- fixed 2 unitialized memory errors - fixed leak in client test
This commit is contained in:
@@ -501,7 +501,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
|
|||||||
MYSQL_TIME *t= (MYSQL_TIME *)ma_get_buffer_offset(stmt, stmt->params[column].buffer_type,
|
MYSQL_TIME *t= (MYSQL_TIME *)ma_get_buffer_offset(stmt, stmt->params[column].buffer_type,
|
||||||
stmt->params[column].buffer, row_nr);
|
stmt->params[column].buffer, row_nr);
|
||||||
char t_buffer[MAX_DATETIME_STR_LEN];
|
char t_buffer[MAX_DATETIME_STR_LEN];
|
||||||
uint len;
|
uint len= 0;
|
||||||
|
|
||||||
int2store(t_buffer + 1, t->year);
|
int2store(t_buffer + 1, t->year);
|
||||||
t_buffer[3]= (char) t->month;
|
t_buffer[3]= (char) t->month;
|
||||||
@@ -512,7 +512,7 @@ int store_param(MYSQL_STMT *stmt, int column, unsigned char **p, unsigned long r
|
|||||||
if (t->second_part)
|
if (t->second_part)
|
||||||
{
|
{
|
||||||
int4store(t_buffer + 8, t->second_part);
|
int4store(t_buffer + 8, t->second_part);
|
||||||
len= 12;
|
len= 11;
|
||||||
}
|
}
|
||||||
else if (t->hour || t->minute || t->second)
|
else if (t->hour || t->minute || t->second)
|
||||||
len= 7;
|
len= 7;
|
||||||
|
@@ -159,6 +159,8 @@ static int bulk2(MYSQL *mysql)
|
|||||||
rc= mysql_stmt_execute(stmt);
|
rc= mysql_stmt_execute(stmt);
|
||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
|
|
||||||
|
mysql_stmt_close(stmt);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -184,7 +184,6 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
|
|||||||
{
|
{
|
||||||
MYSQL_STMT *stmt= 0;
|
MYSQL_STMT *stmt= 0;
|
||||||
uint rc, i, count= row_count;
|
uint rc, i, count= row_count;
|
||||||
ulong length[4]= {0,0,0,0};
|
|
||||||
MYSQL_BIND my_bind[4];
|
MYSQL_BIND my_bind[4];
|
||||||
my_bool is_null[4]= {0,0,0,0};
|
my_bool is_null[4]= {0,0,0,0};
|
||||||
MYSQL_TIME tm[4];
|
MYSQL_TIME tm[4];
|
||||||
@@ -203,7 +202,6 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
|
|||||||
its members.
|
its members.
|
||||||
*/
|
*/
|
||||||
memset(my_bind, '\0', sizeof(my_bind));
|
memset(my_bind, '\0', sizeof(my_bind));
|
||||||
memset(tm, 0, sizeof(tm));
|
|
||||||
|
|
||||||
my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
|
my_bind[0].buffer_type= MYSQL_TYPE_TIMESTAMP;
|
||||||
my_bind[1].buffer_type= MYSQL_TYPE_TIME;
|
my_bind[1].buffer_type= MYSQL_TYPE_TIME;
|
||||||
@@ -214,9 +212,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
|
|||||||
{
|
{
|
||||||
my_bind[i].buffer= (void *) &tm[i];
|
my_bind[i].buffer= (void *) &tm[i];
|
||||||
my_bind[i].is_null= &is_null[i];
|
my_bind[i].is_null= &is_null[i];
|
||||||
my_bind[i].length= &length[i];
|
my_bind[i].buffer_length= sizeof(MYSQL_TIME);
|
||||||
my_bind[i].buffer_length= 30;
|
|
||||||
length[i]= 20;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
second_part= 0;
|
second_part= 0;
|
||||||
@@ -236,6 +232,7 @@ static int test_bind_date_conv(MYSQL *mysql, uint row_count)
|
|||||||
{
|
{
|
||||||
for (i= 0; i < (int) array_elements(my_bind); i++)
|
for (i= 0; i < (int) array_elements(my_bind); i++)
|
||||||
{
|
{
|
||||||
|
memset(&tm[i], 0, sizeof(MYSQL_TIME));
|
||||||
tm[i].neg= 0;
|
tm[i].neg= 0;
|
||||||
tm[i].second_part= second_part+count;
|
tm[i].second_part= second_part+count;
|
||||||
if (my_bind[i].buffer_type != MYSQL_TYPE_TIME)
|
if (my_bind[i].buffer_type != MYSQL_TYPE_TIME)
|
||||||
@@ -3414,7 +3411,6 @@ static int test_double_compare(MYSQL *mysql)
|
|||||||
my_bind[1].buffer= (void *)&real_data;
|
my_bind[1].buffer= (void *)&real_data;
|
||||||
my_bind[1].buffer_length= sizeof(real_data);
|
my_bind[1].buffer_length= sizeof(real_data);
|
||||||
my_bind[1].length= &length[1];
|
my_bind[1].length= &length[1];
|
||||||
length[1]= 10;
|
|
||||||
|
|
||||||
/* double */
|
/* double */
|
||||||
my_bind[2].buffer_type= MYSQL_TYPE_DOUBLE;
|
my_bind[2].buffer_type= MYSQL_TYPE_DOUBLE;
|
||||||
@@ -3422,6 +3418,7 @@ static int test_double_compare(MYSQL *mysql)
|
|||||||
|
|
||||||
tiny_data= 1;
|
tiny_data= 1;
|
||||||
strcpy(real_data, "10.2");
|
strcpy(real_data, "10.2");
|
||||||
|
length[1]= strlen(real_data);
|
||||||
double_data= 34.5;
|
double_data= 34.5;
|
||||||
rc= mysql_stmt_bind_param(stmt, my_bind);
|
rc= mysql_stmt_bind_param(stmt, my_bind);
|
||||||
check_stmt_rc(rc, stmt);
|
check_stmt_rc(rc, stmt);
|
||||||
|
@@ -3028,7 +3028,7 @@ static int test_bug8330(MYSQL *mysql)
|
|||||||
int i, rc;
|
int i, rc;
|
||||||
const char *query= "select a,b from t1 where a=?";
|
const char *query= "select a,b from t1 where a=?";
|
||||||
MYSQL_BIND my_bind[2];
|
MYSQL_BIND my_bind[2];
|
||||||
long lval[2];
|
long lval[2]= {1,2};
|
||||||
|
|
||||||
stmt_text= "drop table if exists t1";
|
stmt_text= "drop table if exists t1";
|
||||||
/* in case some previos test failed */
|
/* in case some previos test failed */
|
||||||
@@ -3354,6 +3354,7 @@ static int test_decimal_bug(MYSQL *mysql)
|
|||||||
*/
|
*/
|
||||||
memset(my_bind, '\0', sizeof(my_bind));
|
memset(my_bind, '\0', sizeof(my_bind));
|
||||||
|
|
||||||
|
memset(data, 0, sizeof(data));
|
||||||
my_bind[0].buffer_type= MYSQL_TYPE_NEWDECIMAL;
|
my_bind[0].buffer_type= MYSQL_TYPE_NEWDECIMAL;
|
||||||
my_bind[0].buffer= (void *)data;
|
my_bind[0].buffer= (void *)data;
|
||||||
my_bind[0].buffer_length= 25;
|
my_bind[0].buffer_length= 25;
|
||||||
|
Reference in New Issue
Block a user