ruby/missing
Peter Zhu d1f14bafb0 Fix leak reported by Valgrind when setting environment variables
The call to setenv replaces the string in the environ array, which causes
the original string to be reported as a memory leak.

This commit allocates another copy of environ called alloc_environ that
contains the strings allocated by ruby_init_setproctitle. Then in
ruby_free_proctitle it frees all the strings in alloc_environ.

For example:

    ENV.each { |k, v| ENV[k] = v.dup }

Valgrind reports:

    3,321 bytes in 39 blocks are definitely lost in loss record 3 of 3
      at 0x484884F: malloc (vg_replace_malloc.c:393)
      by 0x25CB5B: objspace_xmalloc0 (gc.c:11972)
      by 0x40344E: ruby_strdup (util.c:540)
      by 0x59C854: ruby_init_setproctitle (setproctitle.c:143)
      by 0x38CC44: ruby_process_options (ruby.c:3101)
      by 0x234DB1: ruby_options (eval.c:117)
      by 0x15B92E: rb_main (main.c:40)
      by 0x15B92E: main (main.c:59)
2024-05-01 08:54:45 -04:00
..
acosh.c
alloca.c
cbrt.c
close.c
crt_externs.h
crypt.c
crypt.h
des_tables.c
dtoa.c Make dtoa.c buildable alone 2023-07-14 18:35:23 +09:00
erf.c
explicit_bzero.c Remove duplicate #include <string.h> [ci skip] 2023-08-27 23:21:20 +09:00
ffs.c
file.h
flock.c Adjust styles [ci skip] 2022-07-27 18:42:27 +09:00
hypot.c
langinfo.c
lgamma_r.c
memcmp.c
memmove.c
mt19937.c
nan.c
nextafter.c
procstat_vm.c Dump backtraces to an arbitrary stream when using libprocstat 2023-09-26 09:02:37 +09:00
setproctitle.c Fix leak reported by Valgrind when setting environment variables 2024-05-01 08:54:45 -04:00
strchr.c
strerror.c
strlcat.c
strlcpy.c
strstr.c
tgamma.c
x86_64-chkstk.S