changeset 909:18e3ad073b38

Use strtok_r/strtok_s instead of strtok. With its global internal state usage of strtok should be avoided. Patch commited on behalf of Sascha Teichmann.
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 14 Aug 2014 11:24:13 +0200
parents d1c951b3012d
children eaed02defe6a
files cinst/mozilla.c
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/cinst/mozilla.c	Wed Aug 13 19:35:08 2014 +0200
+++ b/cinst/mozilla.c	Thu Aug 14 11:24:13 2014 +0200
@@ -91,6 +91,12 @@
  */
 #define LINEBUFLEN 10000
 
+#ifdef _WIN32
+#define STRTOK_R strtok_s
+#else
+#define STRTOK_R strtok_r
+#endif
+
 /**
  * @brief Global Return Code
  *
@@ -163,6 +169,7 @@
   char *fqpath;
   bool inprofile = false;
   bool relative_path = false;
+  char *saveptr;
 
   if ((inifile = fopen(inifile_name, "r")) != NULL)
     {
@@ -183,8 +190,9 @@
           /* If we are in a profile parse path related stuff */
           if (inprofile)
             {
-              key = strtok(line, "=");
-              value = strtok(NULL, "=");
+              saveptr = NULL;
+              key = STRTOK_R(line, "=", &saveptr);
+              value = STRTOK_R(NULL, "=", &saveptr);
               str_trim(&value);
               if (str_equal(key, "Path"))
                 {

http://wald.intevation.org/projects/trustbridge/