Skip to content

ruby_setenv: Do not allow on multi-threaded programs #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
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
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