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

Commit c29844d0 authored by George Burgess IV's avatar George Burgess IV
Browse files

app_main: silence static analyzer warnings

This silences two warnings:

frameworks/base/cmds/app_process/app_main.cpp:238:11: warning: Potential
memory leak

frameworks/base/cmds/app_process/app_main.cpp:261:9: warning: Potential
memory leak

As the (existing) comment notes, we nuke argv later in main(), so these
copies are necessary. Since these args need to live for basically the
entire life of the process, it seems pointless to go out of our way to
free them.

Bug: 27101951
Test: mma. Static analyzer warnings are gone.
Change-Id: Icbfabfede9db909f6acb274b697cb6076c3fc11f
parent ed3e6d47
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -233,6 +233,9 @@ int main(int argc, char* const argv[])
    for (i = 0; i < argc; i++) {
    for (i = 0; i < argc; i++) {
        if (known_command == true) {
        if (known_command == true) {
          runtime.addOption(strdup(argv[i]));
          runtime.addOption(strdup(argv[i]));
          // The static analyzer gets upset that we don't ever free the above
          // string. Since the allocation is from main, leaking it doesn't seem
          // problematic. NOLINTNEXTLINE
          ALOGV("app_process main add known option '%s'", argv[i]);
          ALOGV("app_process main add known option '%s'", argv[i]);
          known_command = false;
          known_command = false;
          continue;
          continue;
@@ -256,6 +259,9 @@ int main(int argc, char* const argv[])
        }
        }


        runtime.addOption(strdup(argv[i]));
        runtime.addOption(strdup(argv[i]));
        // The static analyzer gets upset that we don't ever free the above
        // string. Since the allocation is from main, leaking it doesn't seem
        // problematic. NOLINTNEXTLINE
        ALOGV("app_process main add option '%s'", argv[i]);
        ALOGV("app_process main add option '%s'", argv[i]);
    }
    }