Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ruby_setenv: Do not allow on multi-threaded programs
  • Loading branch information
Vicent Marti committed Feb 23, 2017
commit 462b4baf33fce4b7876c4269f545941d7ec7858a
9 changes: 9 additions & 0 deletions hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -3382,9 +3382,18 @@ check_envname(const char *name)
}
#endif

static void
check_running_threads(void)
{
if (!rb_thread_alone())
rb_raise(rb_eRuntimeError, "cannot setenv() in a multi-threaded program");
}

void
ruby_setenv(const char *name, const char *value)
{
check_running_threads();

#if defined(_WIN32)
# if defined(MINGW_HAS_SECURE_API) || RUBY_MSVCRT_VERSION >= 80
# define HAVE__WPUTENV_S 1
Expand Down