Changeset 81dabe5 in subsurface


Ignore:
Timestamp:
Jun 27, 2017, 11:03:19 AM (4 weeks ago)
Author:
Linus Torvalds <torvalds@…>
Branches:
master
Children:
57753321
Parents:
4f3a9cdb
git-author:
Alex Blasche <alexander.blasche@…> (06/27/17 04:50:19)
git-committer:
Linus Torvalds <torvalds@…> (06/27/17 11:03:19)
Message:

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@…>
Signed-off-by: Linus Torvalds <torvalds@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/qt-ble.cpp

    rd0c3ef4 r81dabe5  
    4343void BLEObject::addService(const QBluetoothUuid &newService)
    4444{
    45         const char *uuid = newService.toString().toUtf8().data();
    46 
    47         qDebug() << "Found service" << uuid;
    48         if (uuid[1] == '0') {
    49                 qDebug () << " .. ignoring since first digit is '0'";
     45        qDebug() << "Found service" << newService;
     46        bool isStandardUuid = false;
     47        newService.toUInt16(&isStandardUuid);
     48        if (isStandardUuid) {
     49                qDebug () << " .. ignoring standard service";
    5050                return;
    5151        }
     52
    5253        service = controller->createServiceObject(newService, this);
    5354        qDebug() << " .. created service object" << service;
Note: See TracChangeset for help on using the changeset viewer.