mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:43:24 +00:00
Fix incorrect uuid check due to temporary char* in QString::toUtf8()
toUtf8() creates a temporary char* representation which is assigned to uuid. As soon the object created by toUtf8() gets destroyed, the uuid pointer points to releases memory. The intention is to check that we don't have one of the standard 16bit Bluetooth uuids. That's the purpose of QBluetoothUuid::toUInt16(). Signed-off-by: Alex Blasche <alexander.blasche@qt.io> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
4f3a9cdb35
commit
81dabe5ace
1 changed files with 6 additions and 5 deletions
|
@ -42,13 +42,14 @@ void BLEObject::writeCompleted(const QLowEnergyDescriptor &d, const QByteArray &
|
|||
|
||||
void BLEObject::addService(const QBluetoothUuid &newService)
|
||||
{
|
||||
const char *uuid = newService.toString().toUtf8().data();
|
||||
|
||||
qDebug() << "Found service" << uuid;
|
||||
if (uuid[1] == '0') {
|
||||
qDebug () << " .. ignoring since first digit is '0'";
|
||||
qDebug() << "Found service" << newService;
|
||||
bool isStandardUuid = false;
|
||||
newService.toUInt16(&isStandardUuid);
|
||||
if (isStandardUuid) {
|
||||
qDebug () << " .. ignoring standard service";
|
||||
return;
|
||||
}
|
||||
|
||||
service = controller->createServiceObject(newService, this);
|
||||
qDebug() << " .. created service object" << service;
|
||||
if (service) {
|
||||
|
|
Loading…
Add table
Reference in a new issue