diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2017-06-27 13:50:19 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-06-27 11:03:19 -0700 |
commit | 81dabe5ace3091656cdbac57598699bb3b9beea7 (patch) | |
tree | 5afa127e06b675d27df998844fa1b77da0f0fb43 | |
parent | 4f3a9cdb354215f036d51457eef01a066f1cc62f (diff) | |
download | subsurface-81dabe5ace3091656cdbac57598699bb3b9beea7.tar.gz |
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>
-rw-r--r-- | core/qt-ble.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 06adce63a..bed5f5feb 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -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) { |