Fix possible crash while using user defined plugins #1290
+7
−5
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 crash can occur when onComplete is called before response headers are available, but it tries to dereference the pointer. onComplete can be called when the client or server reset the stream / connection, which is a common case, especially under heavy load.
A more robust fix would be changing StreamDecoderCompletionCallback::onComplete to take Envoy::OptRef for the header, and actually check on whether it has value.
The fix currently works because there is only one call site that might have nullptr dereference, which happens to set
success
to false:nighthawk/source/client/stream_decoder.cc
Line 99 in b577192