Seeed-Studio / GPRS_SIM900

library for GPRS shield with sim900 module.
MIT License
138 stars 96 forks source link

Don't dereference null pointers for apn, userName, password #2

Closed metadaddy closed 9 years ago

metadaddy commented 9 years ago

Omitting apn, userName, passWord arguments from call to GPRS::join resulted in errors due to dereferencing the default null values (long string of garbage data was sent to device). Simply test apn, userName, passWord against null before sending them.

ortegafernando commented 9 years ago

Hi,

Have you checked it ? I mean, do you have any sim card that works without APN or USERNAME or PASSWORD ?

Is it ok for you ?

Hope your reply.

metadaddy commented 9 years ago

Yes - I have a SIM that works with only apn, no username or password. It would fail when passing only apn (username, password default to 0, so it would pass garbage to the device). Adding the tests fixes it. I added apn test as well since there is a default parameter for apn also, and dereferencing a null pointer is not a good thing to do!

ortegafernando commented 9 years ago

Thanks a lot, merged.

metadaddy commented 9 years ago

Great - thanks!