Fixed memory leak in query_classifier.
This commit is contained in:
@ -1204,15 +1204,15 @@ inline void add_str(char** buf, int* buflen, int* bufsize, char* str)
|
|||||||
int isize = strlen(str) + 1;
|
int isize = strlen(str) + 1;
|
||||||
if(*buf == NULL || isize + *buflen >= *bufsize)
|
if(*buf == NULL || isize + *buflen >= *bufsize)
|
||||||
{
|
{
|
||||||
char *tmp = (char*)calloc((*bufsize) * 2 + isize, sizeof(char));
|
*bufsize = (*bufsize) * 2 + isize;
|
||||||
if(tmp){
|
char *tmp = (char*)realloc(*buf,(*bufsize)* sizeof(char));
|
||||||
memcpy(tmp,*buf,*bufsize);
|
if(tmp == NULL){
|
||||||
if(*buf){
|
skygw_log_write_flush (LE,"Error: memory reallocation failed");
|
||||||
free(*buf);
|
free(*buf);
|
||||||
|
*buf = NULL;
|
||||||
|
*bufsize = 0;
|
||||||
}
|
}
|
||||||
*buf = tmp;
|
*buf = tmp;
|
||||||
*bufsize = (*bufsize) * 2 + isize;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(*buflen > 0){
|
if(*buflen > 0){
|
||||||
@ -1248,7 +1248,12 @@ char* skygw_get_affected_fields(GWBUF* buf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
lex->current_select = lex->all_selects_list;
|
lex->current_select = lex->all_selects_list;
|
||||||
|
if((where = (char*)malloc(sizeof(char)*1)) == NULL)
|
||||||
|
{
|
||||||
|
skygw_log_write_flush(LE,"Error: Memory allocation failed.");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
*where = '\0';
|
||||||
while(lex->current_select)
|
while(lex->current_select)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user