You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix for potential null pointer access / _initializerCallback not initialized #890
This PR properly initializes _initializerCallback function pointer and checks for its validity before to call it
Thanks @manchoz, however your PR removes completely the callback and this would brake backward compatibility (in case someone used the callback), so I would prefer to keep the callback and just make it safe.
What do you think @pennam ?
@pennam, I could be wrong, but here is my understanding:
you have 3 constructors of EthernetClass (1) EthernetClass(EthernetInterface *_if), (2) EthernetClass();, (3) EthernetClass(voidPrtFuncPtr _cb). _initializerCallback() (which is pointer to function) is initialized using constructor (3) and is not related to eth_if. I agree however on the fact that eth_if could not be nullptr ever, but just because you cannot call the constructor EthernetClass(nullptr) because of the conflict between (1) and (3).
This PR is needed in all cases since _initializeCallback is not properly initialized nor there is a check for its validity when is called.
@maidnl i was thinking if it makes any sense to keep the _initializerCallback() in the code:
using ctor 3 EthernetClass(voidPrtFuncPtr _cb); the _initializerCallback() is never called because eth_if is always different from nullptr
using ctor 2 EthernetClass(); same story
using ctor 1 EthernetClass(EthernetInterface *_if) you can teoretically create an Ethernet object with a null eth_if, but you can't configure the _initializerCallback() 😞
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
fix for potential null pointer access / _initializerCallback not initialized #890
This PR properly initializes _initializerCallback function pointer and checks for its validity before to call it