diff options
author | tradke <tradke@eff87b29-5268-4891-90a3-a07138403961> | 2003-01-06 12:27:52 +0000 |
---|---|---|
committer | tradke <tradke@eff87b29-5268-4891-90a3-a07138403961> | 2003-01-06 12:27:52 +0000 |
commit | 99d8724925641b3654ff7fd8de29c805aad2108a (patch) | |
tree | 3ee6c5a3bf484320cc0010c3ad92546f65eb626f | |
parent | 9c21ff0c0ac207f4701c4479154c0ea4f17bb89a (diff) |
Copy pointers to string parameters to a local variable before modifying it.
This prevents potential future problems in pointer assignments when we declare
a pointer to a string parameters constant.
This closes PR CactusIO/1351.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusIO/IOJpeg/trunk@79 eff87b29-5268-4891-90a3-a07138403961
-rw-r--r-- | src/Startup.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/Startup.c b/src/Startup.c index 58ea1a4..f58a5a0 100644 --- a/src/Startup.c +++ b/src/Startup.c @@ -95,6 +95,7 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) { int i, numvars; ioJpegGH *myGH; + const char *my_out_dir; DECLARE_CCTK_PARAMETERS @@ -135,20 +136,17 @@ static void *SetupGH (tFleshConfig *config, int conv_level, cGH *GH) myGH->out_every_default = out_every - 1; /* get the name for IOJpeg's output directory */ - if (*out_dir == 0) - { - out_dir = io_out_dir; - } + my_out_dir = *out_dir ? out_dir : io_out_dir; /* omit the directory if it's the current working dir */ - if (strcmp (out_dir, ".") == 0) + if (strcmp (my_out_dir, ".") == 0) { myGH->out_dir = strdup (""); } else { - myGH->out_dir = (char *) malloc (strlen (out_dir) + 2); - sprintf (myGH->out_dir, "%s/", out_dir); + myGH->out_dir = (char *) malloc (strlen (my_out_dir) + 2); + sprintf (myGH->out_dir, "%s/", my_out_dir); } /* create the output dir */ |