Fixes to Coverity errors:

72662
72702
72724
73397
73410
73414
73422
75424
75748
75789
75938
75939

Also includes a fix to a bug caused by a previous Coverity error change in canonizer.c
This commit is contained in:
Markus Makela
2014-11-07 11:52:40 +02:00
parent 474f018cee
commit a4caac55c8
5 changed files with 57 additions and 55 deletions

View File

@ -1088,30 +1088,31 @@ char** skygw_get_table_names(GWBUF* querybuf,int* tblsize, bool fullnames)
} }
} }
if(tmp != NULL){
char *catnm = NULL;
char *catnm = NULL; if(fullnames)
{
if(tbl->db && strcmp(tbl->db,"skygw_virtual") != 0)
{
catnm = (char*)calloc(strlen(tbl->db) + strlen(tbl->table_name) + 2,sizeof(char));
strcpy(catnm,tbl->db);
strcat(catnm,".");
strcat(catnm,tbl->table_name);
}
}
if(fullnames) if(catnm)
{ {
if(tbl->db && strcmp(tbl->db,"skygw_virtual") != 0) tables[i++] = catnm;
{ }
catnm = (char*)calloc(strlen(tbl->db) + strlen(tbl->table_name) + 2,sizeof(char)); else
strcpy(catnm,tbl->db); {
strcat(catnm,"."); tables[i++] = strdup(tbl->table_name);
strcat(catnm,tbl->table_name); }
}
}
if(catnm) tbl=tbl->next_local;
{ }
tables[i++] = catnm;
}
else
{
tables[i++] = strdup(tbl->table_name);
}
tbl=tbl->next_local;
} }
lex->current_select = lex->current_select->next_select_in_list(); lex->current_select = lex->current_select->next_select_in_list();
} }

View File

@ -57,7 +57,7 @@ int main(int argc, char** argv)
{ {
fgets(readbuff,4092,infile); fgets(readbuff,4092,infile);
psize = strlen(readbuff); psize = strlen(readbuff);
if(psize < 0 || > 4092){ if(psize < 0 || psize > 4092){
continue; continue;
} }
qbuff = gwbuf_alloc(psize + 7); qbuff = gwbuf_alloc(psize + 7);

View File

@ -1359,7 +1359,7 @@ SERVER *server;
serviceSetUser(obj->element, serviceSetUser(obj->element,
user, user,
auth); auth);
if (enable_root_user && service) if (enable_root_user)
serviceEnableRootUser(service, atoi(enable_root_user)); serviceEnableRootUser(service, atoi(enable_root_user));
if (allow_localhost_match_wildcard_host && service) if (allow_localhost_match_wildcard_host && service)

View File

@ -137,8 +137,8 @@ FILTER_PARAMETER** read_params(int* paramc)
do_read = 0; do_read = 0;
} }
} }
FILTER_PARAMETER** params; FILTER_PARAMETER** params = NULL;
if((params = malloc(sizeof(FILTER_PARAMETER*)*(pc+1)))!=NULL){ if((params = malloc(sizeof(FILTER_PARAMETER*)*(pc+1))) != NULL){
for(i = 0;i<pc;i++){ for(i = 0;i<pc;i++){
params[i] = malloc(sizeof(FILTER_PARAMETER)); params[i] = malloc(sizeof(FILTER_PARAMETER));
if(params[i]){ if(params[i]){
@ -148,9 +148,9 @@ FILTER_PARAMETER** read_params(int* paramc)
free(names[i]); free(names[i]);
free(values[i]); free(values[i]);
} }
params[pc] = NULL;
*paramc = pc;
} }
params[pc] = NULL;
*paramc = pc;
return params; return params;
} }
@ -925,8 +925,9 @@ GWBUF* gen_packet(PACKET pkt)
int process_opts(int argc, char** argv) int process_opts(int argc, char** argv)
{ {
int fd = open_file("harness.cnf",1), buffsize = 1024; unsigned int fd = open_file("harness.cnf",1), buffsize = 1024;
int rd,fsize,rdsz; int rd,rdsz;
unsigned int fsize;
char *buff = calloc(buffsize,sizeof(char)), *tok = NULL; char *buff = calloc(buffsize,sizeof(char)), *tok = NULL;
/**Parse 'harness.cnf' file*/ /**Parse 'harness.cnf' file*/

View File

@ -1425,31 +1425,31 @@ void check_drop_tmp_table(
if (is_drop_table_query(querybuf)) if (is_drop_table_query(querybuf))
{ {
tbl = skygw_get_table_names(querybuf,&tsize,false); tbl = skygw_get_table_names(querybuf,&tsize,false);
if(tbl != NULL){
for(i = 0; i<tsize; i++)
{
klen = strlen(dbname) + strlen(tbl[i]) + 2;
hkey = calloc(klen,sizeof(char));
strcpy(hkey,dbname);
strcat(hkey,".");
strcat(hkey,tbl[i]);
for(i = 0; i<tsize; i++) if (rses_prop_tmp &&
{ rses_prop_tmp->rses_prop_data.temp_tables)
klen = strlen(dbname) + strlen(tbl[i]) + 2; {
hkey = calloc(klen,sizeof(char)); if (hashtable_delete(rses_prop_tmp->rses_prop_data.temp_tables,
strcpy(hkey,dbname); (void *)hkey))
strcat(hkey,"."); {
strcat(hkey,tbl[i]); LOGIF(LT, (skygw_log_write(LOGFILE_TRACE,
"Temporary table dropped: %s",hkey)));
}
}
free(tbl[i]);
free(hkey);
}
if (rses_prop_tmp && free(tbl);
rses_prop_tmp->rses_prop_data.temp_tables) }
{
if (hashtable_delete(rses_prop_tmp->rses_prop_data.temp_tables,
(void *)hkey))
{
LOGIF(LT, (skygw_log_write(LOGFILE_TRACE,
"Temporary table dropped: %s",hkey)));
}
}
free(tbl[i]);
free(hkey);
}
if(tbl != NULL){
free(tbl);
}
} }
} }
@ -1495,7 +1495,7 @@ skygw_query_type_t is_read_tmp_table(
{ {
tbl = skygw_get_table_names(querybuf,&tsize,false); tbl = skygw_get_table_names(querybuf,&tsize,false);
if (tsize > 0) if (tbl != NULL && tsize > 0)
{ {
/** Query targets at least one table */ /** Query targets at least one table */
for(i = 0; i<tsize && !target_tmp_table && tbl[i]; i++) for(i = 0; i<tsize && !target_tmp_table && tbl[i]; i++)