Changeset: 3ecfe198573f for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3ecfe198573f Modified Files: clients/mapiclient/eventparser.c clients/mapiclient/tachograph.c Branch: default Log Message:
Fix argument parsing and be more defensive in re-using structures. diffs (80 lines): diff --git a/clients/mapiclient/eventparser.c b/clients/mapiclient/eventparser.c --- a/clients/mapiclient/eventparser.c +++ b/clients/mapiclient/eventparser.c @@ -37,12 +37,14 @@ parseArguments(char *call) { int i; char *c = call, *l, ch; - char *v; + char *v, *w; malargtop = 0; malvartop = 0; if( debug) - fprintf(stderr,"call:%s\n",call); + fprintf(stderr,"%s\n",call); + memset(malarguments, 0, sizeof(malarguments)); + memset(malvariables, 0, sizeof(malvariables)); for( ; c && *c && malargtop < MAXMALARGS; c++){ if (*c ==')') break; @@ -68,6 +70,8 @@ parseArguments(char *call) *l= 0; malarguments[malargtop++] = strdup(c); c= l+1; + // we could find a type descriptor here, which we skip + while( *c && *c !=',' && *c !=')') c++; } else if(*c) { l = strchr(c, ch = ','); if( l == 0){ @@ -75,6 +79,9 @@ parseArguments(char *call) break; } *l=0; + // we could find a type descriptor as well, which we skip + w= strchr(c,':'); + if( w) *w = 0; malarguments[malargtop++] = strdup(c); *l=ch; c= l; diff --git a/clients/mapiclient/tachograph.c b/clients/mapiclient/tachograph.c --- a/clients/mapiclient/tachograph.c +++ b/clients/mapiclient/tachograph.c @@ -226,10 +226,7 @@ static void resetTachograph(void){ lastpc = 0; pccount = 0; fflush(stdout); - if( events){ - free(events); - events = 0; - } + events = 0; } static char stamp[BUFSIZ]={0}; @@ -304,7 +301,7 @@ static struct{ static void renderArgs(char *c, int len, char *line, char *limit, char *l) { - char varname[BUFSIZ], *v=0; + char varname[BUFSIZ]={0}, *v=0; for(; *c && *c !=')' && l < limit-1; ){ if( *c == ',')*l++= *c++; v= 0; @@ -531,7 +528,7 @@ update(EventRecord *ev) if(ev->fcn && strstr(ev->fcn,"querylog.define") ){ // extract a string argument currentquery = malarguments[0]; - malsize = atoi(malarguments[3]); + malsize = malarguments[2]? atoi(malarguments[2]): 2048; events = (Event*) malloc(malsize * sizeof(Event)); memset((char*)events, 0, malsize * sizeof(Event)); // use the truncated query text, beware that the \ is already escaped in the call argument. @@ -557,6 +554,7 @@ update(EventRecord *ev) } if( ev->tag != currenttag) return; // forget all except one query + assert(ev->pc < malsize); events[ev->pc].state = RUNNING; renderCall(line,BUFSIZ, ev->stmt,0,1); events[ev->pc].stmt = strdup(ev->stmt); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list