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

Commit cb2449f8 authored by George Burgess IV's avatar George Burgess IV Committed by Josh Gao
Browse files

Fix a memory leak

If create_service_thread fails, we'll leak `arg`.

This fixes a static analyzer complaint:
system/core/adb/services.cpp:298:13: warning: Potential leak of memory
pointed to by 'arg'

Bug: None
Test: Reran the static analyzer. No more complaints about this leak.
Change-Id: I5aec7fd78f2cc775b650501b02bdf0039d1647ca
parent 277a95bf
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -296,6 +296,7 @@ int service_to_fd(const char* name, const atransport* transport) {
        void* arg = strdup(name + 7);
        void* arg = strdup(name + 7);
        if (arg == NULL) return -1;
        if (arg == NULL) return -1;
        ret = create_service_thread("reboot", reboot_service, arg);
        ret = create_service_thread("reboot", reboot_service, arg);
        if (ret < 0) free(arg);
    } else if(!strncmp(name, "root:", 5)) {
    } else if(!strncmp(name, "root:", 5)) {
        ret = create_service_thread("root", restart_root_service, nullptr);
        ret = create_service_thread("root", restart_root_service, nullptr);
    } else if(!strncmp(name, "unroot:", 7)) {
    } else if(!strncmp(name, "unroot:", 7)) {