Skip to content

Fix NFD_PickFolder() asserting in debug with non ASCII default path #81

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

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

blep
Copy link

@blep blep commented Mar 28, 2020

  • How to reproduce:
    Call NFD_PickFolder() passing a non ASCII path for defaultPath on Windows with Visual Studio 2019, Win32 64 bits build.

  • Description:
    The sanity check in CopyNFDCharToWChar() assert (called by SetDefaultPath()):

#ifdef _DEBUG
    int inStrCharacterCount = static_cast<int>(NFDi_UTF8_Strlen(inStr));
    assert( ret == inStrCharacterCount );
#else
  • Cause:
    This is caused by right shifting char which is negative, which is implementation defined behavior. I fixed this by casting to a unsigned value before shifting.

I was only able to test this in my own build env (VS 2019), so make sure to run it through your private build bots.

…ndows when given non ASCII path due to incorrect length computed by NFDi_UTF8_Strlen(). Caused by NFDi_UTF8_Strlen() relying on right shifting negative value, which is implementation defined behavior. The issue was fixed by casting to a unsigned value before shifting.
@mlabbe mlabbe merged commit eedbd62 into mlabbe:devel Jan 8, 2021
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

Successfully merging this pull request may close these issues.

2 participants