Skip to content

clone bug in rustc_index::bit_set::BitSet #99006

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
LeeeWee opened this issue Jul 7, 2022 · 0 comments · Fixed by #99052
Closed

clone bug in rustc_index::bit_set::BitSet #99006

LeeeWee opened this issue Jul 7, 2022 · 0 comments · Fixed by #99052
Labels
C-bug Category: This is a bug.

Comments

@LeeeWee
Copy link

LeeeWee commented Jul 7, 2022

In the following code from rust/compiler/rustc_index/src/bit_set.rs, self.words should resize with from.words.len() instead of from.domain_size.

    fn clone_from(&mut self, from: &Self) {
        if self.domain_size != from.domain_size {
            self.words.resize(from.domain_size, 0);
            self.domain_size = from.domain_size;
        }

        self.words.copy_from_slice(&from.words);
    }

Otherwise, this function will panic when calling 'copy_from_slice' because of the mismatched slice length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant