summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--missing/setproctitle.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/missing/setproctitle.c b/missing/setproctitle.c
index d718123802..f90886671c 100644
--- a/missing/setproctitle.c
+++ b/missing/setproctitle.c
@@ -153,18 +153,16 @@ ruby_free_proctitle(void)
if (!orig_environ) return; /* environ is allocated by OS */
- for (int i = 0; environ[i] != NULL; i++) {
- xfree(environ[i]);
- }
-
- /* ruby_setenv could allocate a new environ, so we need to free both environ
- * orig_environ in that case. */
+ /* ruby_setenv could allocate a new environ, so we need to free orig_environ
+ * in that case. */
if (environ != orig_environ) {
+ for (int i = 0; orig_environ[i] != NULL; i++) {
+ xfree(orig_environ[i]);
+ }
+
xfree(orig_environ);
orig_environ = NULL;
}
-
- xfree(environ);
#endif
}