Skip to content

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

@jorgenpt

Description

@jorgenpt

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. :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions