africastalking.Net icon indicating copy to clipboard operation
africastalking.Net copied to clipboard

Possible NullReference Exception

Open tmacharia opened this issue 3 years ago • 2 comments

https://github.com/AfricasTalkingLtd/africastalking.Net/blob/640b1955ffbe7f28da0a14fd1adfdab08813bad7/AfricasTalkingCS/AfricasTalkingGateway.cs#L398

Hi, this check will fail when a string in null since you can't call .Length on a null string object.

I would suggest using String.IsNullOrWhiteSpace(String) to do the check.

You can create a test case wherein you pass null for phoneNumber/shortCode/keyWord and see that a NullObjectReferenceException is thrown instead of the anticipated AfricasTalkingGatewayException

tmacharia avatar May 24 '21 18:05 tmacharia

Nice catch, would you mind sending a PR with a minor version bump...

TheBeachMaster avatar Jun 08 '21 19:06 TheBeachMaster

Let me see.

tmacharia avatar Jun 08 '21 19:06 tmacharia