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

Commit 14dadb1e authored by George Burgess IV's avatar George Burgess IV Committed by George Burgess
Browse files

libmediametrics: fix a memory leak

The memory returned here is malloc()ated, and it's not clear that
submitBuffer is intended to free it. Do so.

Caught by the static analyzer:
> frameworks/av/media/libmediametrics/MediaMetricsItem.cpp:287:16:
warning: Potential leak of memory pointed to by 'str'
[clang-analyzer-unix.Malloc]

Bug: 179814879
Test: TreeHugger tests
Change-Id: Id0320fb7fe4567b79131884f73e2a73b153039d8
parent a8672abd
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -285,6 +285,7 @@ bool mediametrics::Item::selfrecord() {
    status_t status = writeToByteString(&str, &size);
    if (status == NO_ERROR) {
        status = submitBuffer(str, size);
        free(str);
    }
    if (status != NO_ERROR) {
        ALOGW("%s: failed to record: %s", __func__, this->toString().c_str());