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

enum_values and enum_keys creates infinite iterators if you don't open the key with read permissions #43

Open
jorgenpt opened this issue May 14, 2021 · 0 comments

Comments

@jorgenpt
Copy link

The following code will never terminate (until it runs out of memory):

fn main() {
    if let Ok(key) = winreg::RegKey::predef(HKEY_CURRENT_USER)
        .open_subkey_with_flags(r"SOFTWARE\Classes\tel", winreg::enums::KEY_SET_VALUE)
    {
        let _: Vec<_> = key.enum_values().collect();
    }
}

While the problem is obvious (you need to include winreg::enums::KEY_READ), the failure case is confusing. It might be more intuitive if enum_values (and presumably enum_keys) returned a single Err for the ERROR_ACCESS_DENIED, returned an empty iterator, or had a return value of io::Result<EnumValues> instead. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant