bsquare-corp / modbus-sphere-library

A Modbus Library and example code suitable for use on Microsoft Sphere devices. Supports Modbus TCP, Modbus RTU and Modbus RTU over TCP.
MIT License
9 stars 7 forks source link

NULL return not checked when creating IP handles #2

Closed glynj-bsquare closed 4 years ago

glynj-bsquare commented 4 years ago

ModbusConnectTcp and ModbusConnectRtuOverTcp both call ModbusConnectIp to get a handle. If the IP connection fails (e.g. times out as the device fails to respond or can't be reached) then it returns NULL. Both the above functions fail to check the handle and try to access it immediately, causing a null pointer exception.