microsoft / wil

Windows Implementation Library
MIT License
2.57k stars 234 forks source link

key_iterator_data string corruption #441

Closed HO-COOH closed 6 months ago

HO-COOH commented 6 months ago

I was using this code to enumerating registry subkeys and use the .name member to concat strings to get subkey values

for (auto& key : wil::make_range(wil::reg::key_iterator{ hParentKey.get() }, wil::reg::key_iterator{}))
{
    ....
    auto value = wil::reg::try_get_value_string(..., parentKey + key.name, ...
}

Then I found out the parameter parentKey + key.name passed to try_get_value_string is getting trimmed. Looking at the key.name member, the string's size is wrong. image

dunhor commented 6 months ago

What "release" of WIL are you using? @ChrisGuzak does this look like the same issue that you reported a while ago that was later fixed?

HO-COOH commented 6 months ago

Confirmed. I was using this release that has the issue (this might be the version coming from the winui3 C++ project template or whatever) image

Upgrading to image solves the issue