diff options
author | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-11-07 00:19:15 +0000 |
---|---|---|
committer | goodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac> | 2001-11-07 00:19:15 +0000 |
commit | e750e45c9b3ad52763a99452fc3d33bdb4d79318 (patch) | |
tree | 55085f18fca489b833ffa737de631c2a3762be5e /src/main | |
parent | afd6f53a51a80f0a83b0e973cea1dbe2a1178bfb (diff) |
Fixing some unprotected mallocs spotted by Ian Hawke.
Tom
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2458 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/ActiveThorns.c | 6 | ||||
-rw-r--r-- | src/main/Parameters.c | 9 | ||||
-rw-r--r-- | src/main/Stagger.c | 8 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/main/ActiveThorns.c b/src/main/ActiveThorns.c index 338775c1..d78cba52 100644 --- a/src/main/ActiveThorns.c +++ b/src/main/ActiveThorns.c @@ -216,12 +216,11 @@ int CCTKi_RegisterThorn(const struct iAttributeList *attributes) if(thorn) { - thorn->implementation = (char *)malloc(sizeof(char)*(strlen(imp)+1)); + thorn->implementation = Util_Strdup(imp); if(thorn->implementation) { /* Fill out data for the thorn. */ - strcpy(thorn->implementation, imp); thorn->active = 0; /* Store the data in the tree */ @@ -327,8 +326,7 @@ int CCTKi_ActivateThorn(const char *name) thorn->active = 1; imp->active = 1; /* Remember which thorn activated this imp. */ - imp->activating_thorn = (char *)malloc(sizeof(char)*(strlen(name)+1)); - strcpy(imp->activating_thorn, name); + imp->activating_thorn = Util_Strdup(name); retval = 0; } else diff --git a/src/main/Parameters.c b/src/main/Parameters.c index 6dba540d..c5b65aa8 100644 --- a/src/main/Parameters.c +++ b/src/main/Parameters.c @@ -725,6 +725,10 @@ int CCTK_ParameterWalk (int first, static t_param *prev_startpoint_all = NULL; static t_param *prev_startpoint_thorn = NULL; + /* FIXME : This routine has become extremely ugly: + * It should only have one return in it. + * The malloc failure should be flagged. + */ /* determine the startpoint for search */ if (! first) @@ -785,7 +789,10 @@ int CCTK_ParameterWalk (int first, *pfullname = (char *) malloc (strlen (prefix) + strlen (startpoint->props->name) + 3); - sprintf (*pfullname, "%s::%s", prefix, startpoint->props->name); + if(*pfullname) + { + sprintf (*pfullname, "%s::%s", prefix, startpoint->props->name); + } } if (pdata) diff --git a/src/main/Stagger.c b/src/main/Stagger.c index 95991e3a..ee0f635f 100644 --- a/src/main/Stagger.c +++ b/src/main/Stagger.c @@ -389,7 +389,7 @@ int CCTKi_ParseStaggerString(int dim, int i,m; int base = 1; int scode = 0; - char *hs; + char hs[11]; if (dim>10) { @@ -398,8 +398,6 @@ int CCTKi_ParseStaggerString(int dim, dim); } - hs = (char*)malloc(11*sizeof(char)); - /* change possible SHORTCUTS into the official notation*/ if (CCTK_Equals(stype,"NONE")) { @@ -438,7 +436,5 @@ int CCTKi_ParseStaggerString(int dim, base = 3 * base; } - free(hs); - - return(scode); + return scode; } |