Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an infinite loop in replace_all() when the search string is empty
The empty string is found at the start of the string, pos = 0, and replaced over and over again. If the replacement string is also empty, the size of the data string will not change. If the replacement string is not empty, it will be repeatedly prepended to the data string. While most callers are careful to ensure the search string is not empty, PosixActivator::update_prompt() lost this property in "Micromamba: Substitute env vars in .condarc (mamba-org#1423)" (9e5f8fd). Rather than restore the check in the caller, fix the root of the issue in replace_all() itself. I ran into this bug as a Micromamba user in a particular set of circumstances where the CONDA_PROMPT_MODIFIER env var was the empty string.¹ It manifested to me the user as a `micromamba create` invocation hanging at the linking phase for any package with a post-link script (such as openmpi). The generated post-link script wrapper invoked, indirectly, `micromamba shell --shell bash activate <path>` which was hanging during update_prompt(). ¹ nextstrain/cli#223 (comment)
- Loading branch information