Fixed canonizer.c passing NULL to various functions.

This commit is contained in:
Markus Makela
2014-09-04 18:19:15 +03:00
parent a8700c12a1
commit 2c470d7bf4

View File

@ -66,10 +66,15 @@ int main(int argc, char** argv)
qbuff = malloc(sizeof(GWBUF*)*lines);
for(i = 0;i<lines;i++){
qbuff[i] = NULL;
}
i = 0;
tok = strtok(buffer,"\n");
while(tok){
if(strlen(tok) > 0){
qin = strdup(tok);
psize = strlen(qin);
qbuff[i] = gwbuf_alloc(psize + 6);
@ -83,10 +88,12 @@ int main(int argc, char** argv)
free(qin);
i++;
}
}
fdout = open(argv[2],O_TRUNC|O_CREAT|O_WRONLY,S_IRWXU|S_IXGRP|S_IXOTH);
for(i = 0;i<lines;i++){
if(qbuff[i]){
parse_query(qbuff[i]);
tok = skygw_get_canonical(qbuff[i]);
write(fdout,tok,strlen(tok));
@ -94,6 +101,8 @@ int main(int argc, char** argv)
gwbuf_free(qbuff[i]);
}
}
close(fdin);
close(fdout);