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

Fixing incorrect buffer in WideCharToMultiByte call in wc2mb (charset.cpp) #480

Merged
merged 2 commits into from Sep 1, 2019
Merged

Fixing incorrect buffer in WideCharToMultiByte call in wc2mb (charset.cpp) #480

merged 2 commits into from Sep 1, 2019

Conversation

dnso86
Copy link
Contributor

@dnso86 dnso86 commented Aug 28, 2019

I noticed that form.icon() did not work properly under MinGW - long story short, turns out that the WideCharToMultiByte call got an incorrect cbMultiByte parameter - thus returned an ERROR_INSUFFICIENT_BUFFER error.

  • mbstr.resize(bytes - 1); is correct - that is counted without the terminating zero.
  • cbMultiByte, however is "Size, in bytes, of the buffer indicated by lpMultiByteStr." so the terminating zero must be counted too.

I am not sure how to proceed with adding checks for all return values of all of the Stringapiset.h calls here, so I'll leave that for later. Ideally wc2mb should have failed though.

@cnjinhao cnjinhao merged commit 6d625a1 into cnjinhao:hotfix-1.7.2 Sep 1, 2019
@cnjinhao
Copy link
Owner

cnjinhao commented Sep 1, 2019

Thank you for fixing this issue!

@dnso86 dnso86 deleted the dnso86-patch-wc2mb branch September 2, 2019 07:39
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.

None yet

2 participants