gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r30658 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r30658 - gnunet/src/testbed
Date: Mon, 11 Nov 2013 10:48:09 +0100

Author: harsha
Date: 2013-11-11 10:48:09 +0100 (Mon, 11 Nov 2013)
New Revision: 30658

Modified:
   gnunet/src/testbed/gnunet-helper-testbed.c
Log:
-fix leaks with putenv()

Modified: gnunet/src/testbed/gnunet-helper-testbed.c
===================================================================
--- gnunet/src/testbed/gnunet-helper-testbed.c  2013-11-11 08:56:37 UTC (rev 
30657)
+++ gnunet/src/testbed/gnunet-helper-testbed.c  2013-11-11 09:48:09 UTC (rev 
30658)
@@ -338,7 +338,7 @@
   char *config;
   char *xconfig;
   char *evstr;
-  char *str;
+  //char *str;
   size_t config_size;
   uLongf ul_config_size;
   size_t xconfig_size;
@@ -407,7 +407,8 @@
   if (NULL != evstr)
   {
 #if WINDOWS
-    GNUNET_break (0 == putenv (GNUNET_TESTING_PREFIX "="));
+    static char *evar = GNUNET_TESTING_PREFIX "=";
+    GNUNET_break (0 == putenv (evar));
 #else
     GNUNET_break (0 == unsetenv (GNUNET_TESTING_PREFIX));
 #endif
@@ -417,11 +418,11 @@
                                     NULL);
   if (NULL != evstr)
   {
-    GNUNET_assert (0 < GNUNET_asprintf (&str, 
+    static char evar[2* PATH_MAX];
+
+    GNUNET_assert (0 < GNUNET_snprintf (evar, sizeof (evar),
                                         GNUNET_TESTING_PREFIX "=%s", evstr));
-    putenv (str);
-    /* do not free str will be consumed by putenv */
-    str = NULL;
+    putenv (evar);
     /* do not free evstr */
     evstr = NULL;
   }
@@ -444,11 +445,15 @@
   }
   LOG_DEBUG ("Staring testbed with config: %s\n", config);
   binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-testbed");
-  /* expose testbed configuration through env variable */
-  GNUNET_assert (0 < GNUNET_asprintf (&evstr, "%s=%s", ENV_TESTBED_CONFIG, 
config));
-  GNUNET_assert (0 == putenv (evstr)); /* Do NOT free evstr; it is consumed by
-                                          putenv */
-  evstr = NULL;
+  {
+    static char evar[2 * PATH_MAX];
+
+    /* expose testbed configuration through env variable */
+    GNUNET_assert (0 < GNUNET_snprintf (evar, sizeof (evar),
+                                        "%s=%s", ENV_TESTBED_CONFIG, config));
+    GNUNET_assert (0 == putenv (evar));
+    evstr = NULL;
+  }
   testbed =
       GNUNET_OS_start_process (PIPE_CONTROL,
                                GNUNET_OS_INHERIT_STD_ERR /*verbose? */ , NULL,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]