From f782523a10f7012d3bfefceee546148bb689c8b1 Mon Sep 17 00:00:00 2001 From: schnetter Date: Mon, 22 Jun 2009 03:12:48 +0000 Subject: Correct segmentation fault. Some time names are still parsed wrong. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPDExtra/trunk@75 61ea717e-8e0c-4c3c-b38e-e9c67f54f1f1 --- src/TimerInfo.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/TimerInfo.c b/src/TimerInfo.c index 84d07a9..e7c689a 100644 --- a/src/TimerInfo.c +++ b/src/TimerInfo.c @@ -364,7 +364,7 @@ static int TimerInfoPage(const cGH *cctkGH, httpRequest *request, void *data) { /* fill out timer info for timer number nr into tdata */ CCTK_TimerI(nt, tdata); - /* start table row */ + /* start table row */ SetToCString(message, "\n"); /* timer type, first column */ @@ -418,7 +418,7 @@ static int TimerInfoPage(const cGH *cctkGH, httpRequest *request, void *data) ConcatDouble(message, tdata->vals[nc].val.d); } /* old value = new value */ - TI_oldtimes[nc][nt]=tdata->vals[nc].val.d; + TI_oldtimes[nc][nt]=tdata->vals[nc].val.d; break; default: @@ -542,8 +542,8 @@ static int TI_insertElement(char* selem) /* if the next insert would overflow the array, increase the array size by 30 elements */ if ( TI_nettypes >= TI_maxnettypes ) { - TI_ettypes=realloc(TI_ettypes, (TI_maxnettypes+30)*sizeof(char*)); TI_maxnettypes+=30; + TI_ettypes=realloc(TI_ettypes, TI_maxnettypes*sizeof(char*)); } /* out of memory ? */ if (TI_ettypes==NULL) return 1; @@ -632,7 +632,6 @@ static char* TI_thornName(const char* tn) { int i; int sl=strlen(tn)+1; - char* ps; char* temp=(char*) malloc(sl); /* cut '[xxxx]' and break before the ':' */ @@ -671,6 +670,12 @@ static char* TI_funcName(const char* tn) if (tn[i]==':') break; } i+=2; + if (i>sl-1) + { + free (ps); + free (temp); + return strdup("malformed timer name"); + } strncpy(temp, tn+i, sl-i); temp[sl-i]='\0'; @@ -686,7 +691,9 @@ static char* TI_funcName(const char* tn) } else { - return "no schedule bin"; + free (ps); + free (temp); + return strdup("no schedule bin"); } free(temp); -- cgit v1.2.3