Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e17f40a authored by jiabin's avatar jiabin
Browse files

APM: Do not add null DeviceDescriptor to DeviceVector.

It make no sense to have null pointer kept in DeviceVector. In that
case, never add null to DeviceVector.

Bug: 162772516
Test: make
Change-Id: Iebf850189de025be9fe205ef0797eb4660898cae
parent 3dd716be
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -227,6 +227,7 @@ void DeviceVector::add(const DeviceVector &devices)
{
    bool added = false;
    for (const auto& device : devices) {
        ALOG_ASSERT(device != nullptr, "Null pointer found when adding DeviceVector");
        if (indexOf(device) < 0 && SortedVector::add(device) >= 0) {
            added = true;
        }
@@ -238,6 +239,7 @@ void DeviceVector::add(const DeviceVector &devices)

ssize_t DeviceVector::add(const sp<DeviceDescriptor>& item)
{
    ALOG_ASSERT(item != nullptr, "Adding null pointer to DeviceVector");
    ssize_t ret = indexOf(item);

    if (ret < 0) {