Skip to content

BLE: nil pointer dereference on disconnect possible #1157

@gen2thomas

Description

@gen2thomas

To initiate a retry after a failing "robot.Start()", an "robot.Stop()" could be useful to get rid of all devices, which are successfully connected until this point.

If the BLE device was not connected at this time, the disconnect fails because the "extDevice" is still not defined in btwrapper.go.

// Disconnect from the BLE device. This method is non-blocking and does not wait until the connection is fully gone.
func (btd *btDevice) disconnect() error {
	return btd.extDevice.Disconnect()
}

this needs to be changed to something like this:

// Disconnect from the BLE device. This method is non-blocking and does not wait until the connection is fully gone.
func (btd *btDevice) disconnect() error {
        if btd!=nil && btd.extDevice!= nil{
            return btd.extDevice.Disconnect()
        }
	return nil
}

Metadata

Metadata

Assignees

Labels

bugdone on devthe feature or bug is solved on dev branch and wait for merge to release branch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions