Add more HRESULT checks to fix null pointer dereferences #45
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.
Hello again!
Thanks again for this very useful project! After the merge of #42, that issue went away, but new null pointer dereference issues appeared in our bug tracker. I had a look at it and found the following:
On multiple places, there is an interaction with
endpointVolume
and the function is expected to return something, but the return value ofendpointVolume
is not checked. Therefore, undefined values may be returned. This PR adds return value checks with default values as return values for failingendpointVolume
interactions. This should fix null pointer dereference issues.For the record, here is the stack trace that I initially triaged:
Instruction with the issue:
mov rax, [rcx]
. rcx is clearly NULL and therefore can't be dereferenced.The stack trace points to the following lines of code: https://github.com/m1dugh/native-sound-mixer/blob/master/cppsrc/win/win-sound-mixer.cpp#L235-L236:
Please note that I still don't have a setup to compile and test this myself and therefore the code is NOT tested. @m1dugh can you have a look at it?
I was not able to reproduce the error myself, but maybe you can try disabling your audio card in the Windows settings to create a faulty audio device that may trigger these errors.