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

Commit 982e2a50 authored by Pirama Arumuga Nainar's avatar Pirama Arumuga Nainar
Browse files

Ignore deliberate free() of non-heap memory

Bug: http://b/181927912

Clang already has -Wfree-nonheap-object but it became a default warning
with clang-r416183

Test: compile crasher.cpp
Change-Id: Ice532e9f373a628e07acd08a4fc7bfa7cf5d4e08
parent f85f3d62
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@ cc_defaults {
        "-Werror",
        "-O0",
        "-fstack-protector-all",
        "-Wno-free-nonheap-object",
        "-Wno-date-time",
    ],
    srcs: ["crasher.cpp"],
+4 −0
Original line number Diff line number Diff line
@@ -134,10 +134,14 @@ noinline int crash(int a) {
    return a*2;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfree-nonheap-object"

noinline void abuse_heap() {
    char buf[16];
    free(buf); // GCC is smart enough to warn about this, but we're doing it deliberately.
}
#pragma clang diagnostic pop

noinline void leak() {
    while (true) {