error_info_fallback needs to convert empty message #711
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The OS version of RoOriginateLanguageException converts empty messages into an error message produced by FormatMessage. Our fallback Win7 version does not have this feature, which causes errors to be produced with no message.
This defect had been present since inception but was exposed by a correctness fix to
hstring.c_str()so that it returned an empty string (instead of nullptr) for the null hstring.Prior to the hstring fix, the implementation of
error_info_fallback::GetErrorDetailswould happily passnullptrtoSysAllocString, which failed with an invalid parameter. This error was propagated (mistakenly aserror_bad_alloc), and that causedhresult_error.message()to fall back toFormatMessage.With the hstring fix, the implementation of
error_info_fallback::GetErrorDetailsnow passes a non-null empty string, whichSysAllocStringdutifully allocates and returns.We fix
error_info_fallbackby having it autogenerate a message if no message was provided, bringing it into alignment with theRoOriginateLanguageExceptionfunction it was intended to emulate.Fixes #623