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

Commit a9546838 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Remove heap allocations from Parcel::enforceInterface" am: 107b205e

Change-Id: I54150f59b26ef1cf004547b1291ef8568da55deb
parents e643c3e6 107b205e
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -557,6 +557,13 @@ bool Parcel::checkInterface(IBinder* binder) const

bool Parcel::enforceInterface(const String16& interface,
                              IPCThreadState* threadState) const
{
    return enforceInterface(interface.string(), interface.size(), threadState);
}

bool Parcel::enforceInterface(const char16_t* interface,
                              size_t len,
                              IPCThreadState* threadState) const
{
    // StrictModePolicy.
    int32_t strictPolicy = readInt32();
@@ -584,12 +591,15 @@ bool Parcel::enforceInterface(const String16& interface,
        return false;
    }
    // Interface descriptor.
    const String16 str(readString16());
    if (str == interface) {
    size_t parcel_interface_len;
    const char16_t* parcel_interface = readString16Inplace(&parcel_interface_len);
    if (len == parcel_interface_len &&
            (!len || !memcmp(parcel_interface, interface, len * sizeof (char16_t)))) {
        return true;
    } else {
        ALOGW("**** enforceInterface() expected '%s' but read '%s'",
                String8(interface).string(), String8(str).string());
              String8(interface, len).string(),
              String8(parcel_interface, parcel_interface_len).string());
        return false;
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -96,6 +96,9 @@ public:
    // passed in.
    bool                enforceInterface(const String16& interface,
                                         IPCThreadState* threadState = nullptr) const;
    bool                enforceInterface(const char16_t* interface,
                                         size_t len,
                                         IPCThreadState* threadState = nullptr) const;
    bool                checkInterface(IBinder*) const;

    void                freeData();