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

Commit 1f7f7253 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "fix LogEvent memory leak"

parents 3367c05b c1fe6f46
Loading
Loading
Loading
Loading
+9 −5
Original line number Original line Diff line number Diff line
@@ -62,13 +62,14 @@ void LogEvent::init() {
        const char* buffer;
        const char* buffer;
        size_t len = android_log_write_list_buffer(mContext, &buffer);
        size_t len = android_log_write_list_buffer(mContext, &buffer);
        // turns to reader mode
        // turns to reader mode
        mContext = create_android_log_parser(buffer, len);
        android_log_context contextForRead = create_android_log_parser(buffer, len);
        init(mContext);
        if (contextForRead) {
            init(contextForRead);
            // destroy the context to save memory.
            // destroy the context to save memory.
        if (mContext) {
            // android_log_destroy will set mContext to NULL
            // android_log_destroy will set mContext to NULL
            android_log_destroy(&mContext);
            android_log_destroy(&contextForRead);
        }
        }
        android_log_destroy(&mContext);
    }
    }
}
}


@@ -188,6 +189,9 @@ void increaseField(Field *field, bool is_child) {
 * of the elements that are written to the log.
 * of the elements that are written to the log.
 */
 */
void LogEvent::init(android_log_context context) {
void LogEvent::init(android_log_context context) {
    if (!context) {
        return;
    }
    android_log_list_element elem;
    android_log_list_element elem;
    // TODO: The log is actually structured inside one list.  This is convenient
    // TODO: The log is actually structured inside one list.  This is convenient
    // because we'll be able to use it to put the attribution (WorkSource) block first
    // because we'll be able to use it to put the attribution (WorkSource) block first