Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cfis
Copy link
Contributor

@cfis cfis commented Apr 20, 2023

On Windows FormatMessageA can return a NULL message - for example when trying to load a 32bit dll from a 64 bit program (garbage.so in the test suite). Since the passed in buffer contains junk data the resulting error message is made up of garbage characters which makes it impossible to know what the problem is.

This commit updates the message so that it always returns the error code (in this case 193) plus message, which makes it possible to debug the problem.

…n trying to load a 32bit dll from a 64 bit program (garbage.so in the test suite). Since the passed in buffer contains junk data the resulting error message full of garbage characters which makes it impossible to know what the problem is.

This commit updates the message so that it at least returns the error code (in this case 193) which makes it possible to debug the problem.
@larskanis larskanis merged commit a17aeb8 into ffi:master Apr 20, 2023
@larskanis
Copy link
Member

Looks good! Thank you!

@larskanis
Copy link
Member

Oh, just noticed that FORMAT_MESSAGE_ALLOCATE_BUFFER allocates a buffer which should be freed by LocalFree(). This could be right after snprintf(). Or do I miss something?

@cfis
Copy link
Contributor Author

cfis commented Apr 20, 2023

Oh you are right! I'll push another MR.

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