Skip to content
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

Fix undefined behavior when getting the current working directory from std::filesystem #728

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

giacomofiorin
Copy link
Member

Adds two functions colvarproxy_io::get_current_work_dir() and colvarproxy_io::join_paths() to replace the code currently used in colvarbias_meta.cpp. It's possible that these may be removed again sometime in the future.

Fixes #726

@giacomofiorin giacomofiorin added the bugfix To be used only in PRs label Oct 12, 2024
Copy link

@al42and al42and left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few nitpicks


// Legacy code
size_t constexpr buf_size = 3001;
std::string cwd;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

@@ -38,6 +38,12 @@ class colvarproxy_io {
// Returns error code
virtual int set_frame(long int);

/// Get the current working directory of this process
virtual std::string get_current_work_dir() const;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it need to be virtual? I think it can even be static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix To be used only in PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent GETCWD in src/colvarbias_meta.cpp can cause underfined behavior
3 participants