QC: Always set number of returned items

qc_get_table_names() and qc_get_database_names() now always set
the number items, also in case of error. That is, it is now always
safe to start iterating using the number of items without first
checking the returned pointer.
This commit is contained in:
Johan Wikman 2016-12-09 13:06:26 +02:00
parent 12f0886ca2
commit ebca707335
2 changed files with 5 additions and 5 deletions

View File

@ -1342,11 +1342,7 @@ char** qc_get_table_names(GWBUF* querybuf, int* tblsize, bool fullnames)
} /*< while(lex->current_select) */
retblock:
if (tblsize)
{
*tblsize = i;
}
*tblsize = i;
return tables;
}

View File

@ -2971,6 +2971,8 @@ static char** qc_sqlite_get_table_names(GWBUF* query, int* tblsize, bool fullnam
char** table_names = NULL;
QC_SQLITE_INFO* info = get_query_info(query);
*tblsize = 0;
if (info)
{
if (qc_info_is_valid(info->status))
@ -3054,6 +3056,8 @@ static char** qc_sqlite_get_database_names(GWBUF* query, int* sizep)
char** database_names = NULL;
QC_SQLITE_INFO* info = get_query_info(query);
*sizep = 0;
if (info)
{
if (qc_info_is_valid(info->status))