Fix FileDropper to properly clone string variables before storing them #18403
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix an issue I spotted while testing this PR.
The way
register_files_for_cleanup
andregister_dirs_for_cleanup
store the strings in@dropped_files
and@dropped_dirs
can cause issues when the array passed as argument contains references to a string variable.Please see this comment for a detailed example of what could happen.
Verification
A basic example would be:
mkdir
takes care of callingregister_dirs_for_cleanup
and will end up having@dropped_dirs
with three identical entries:After this fix,
@dropped_dirs
should contains the expected entries:Maybe the easiest way to test this is to follow the steps in the PR I mentioned earlier and make sure the expected directories are correctly cleaned up.