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

Commit 692a5cc9 authored by Alexy Joseph's avatar Alexy Joseph
Browse files

hal: Fix potential memory leaks in HAL

Fix potential memory leaks in HAL

Change-Id: Ifd491cc185a7d1afa647f03639e57d1685d18803
parent 80f4a45a
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2014 The Android Open Source Project
@@ -351,6 +351,7 @@ void audio_extn_utils_update_streams_output_cfg_list(void *platform,
    root = config_node("", "");
    if (root == NULL) {
        ALOGE("cfg_list, NULL config root");
        free(data);
        return;
    }

@@ -358,6 +359,9 @@ void audio_extn_utils_update_streams_output_cfg_list(void *platform,
    load_output(root, platform, streams_output_cfg_list);

    send_app_type_cfg(platform, mixer, streams_output_cfg_list);

    config_free(root);
    free(data);
}

void audio_extn_utils_dump_streams_output_cfg_list(
+24 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
 * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2013 The Android Open Source Project
@@ -1986,7 +1986,7 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k
{
    struct stream_out *out = (struct stream_out *)stream;
    struct str_parms *query = str_parms_create_str(keys);
    char *str;
    char *str = (char*) NULL;
    char value[256];
    struct str_parms *reply = str_parms_create();
    size_t i, j;
@@ -1994,6 +1994,12 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k
    bool first = true;

    if (!query || !reply) {
        if (reply) {
            str_parms_destroy(reply);
        }
        if (query) {
            str_parms_destroy(query);
        }
        ALOGE("out_get_parameters: failed to allocate mem for query or reply");
        return NULL;
    }
@@ -2039,6 +2045,8 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k
            strlcat(value, "false", sizeof(value));
        }
        str_parms_add_str(reply, "is_direct_pcm_track", value);
        if (str)
            free(str);
        str = str_parms_to_str(reply);
    }

@@ -2061,6 +2069,8 @@ static char* out_get_parameters(const struct audio_stream *stream, const char *k
            i++;
        }
        str_parms_add_str(reply, AUDIO_PARAMETER_STREAM_SUP_FORMATS, value);
        if (str)
            free(str);
        str = str_parms_to_str(reply);
    }
    str_parms_destroy(query);
@@ -2620,6 +2630,12 @@ static char* in_get_parameters(const struct audio_stream *stream,
    struct str_parms *reply = str_parms_create();

    if (!query || !reply) {
        if (reply) {
            str_parms_destroy(reply);
        }
        if (query) {
            str_parms_destroy(query);
        }
        ALOGE("in_get_parameters: failed to create query or reply");
        return NULL;
    }
@@ -3340,6 +3356,12 @@ static char* adev_get_parameters(const struct audio_hw_device *dev,
    int ret = 0;

    if (!query || !reply) {
        if (reply) {
            str_parms_destroy(reply);
        }
        if (query) {
            str_parms_destroy(query);
        }
        ALOGE("adev_get_parameters: failed to create query or reply");
        return NULL;
    }