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

Commit e851bdd5 authored by Anver sadhique's avatar Anver sadhique
Browse files

audio-hal: handling resource leak for variable 'params'

Variable “params” will not be released if it is returned directly.
So added return variable and released params before calling return.

Change-Id: I3c39e397402eaf1792d43b8fbe6765e8b36fc831
parent b9216d85
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
/*
* Copyright (c) 2016-2020, The Linux Foundation. All rights reserved.
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -430,10 +430,13 @@ int on_dev_event(dev_event_t *dev_event)
    snprintf(val, sizeof(val), "%s,%s", dev_event->dev,
             dev_event->status ? "ON" : "OFF");

    if (str_parms_add_str(params, AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE, val) < 0)
        return -1;
    int ret = 0;

    int ret = notify(params);
    if (str_parms_add_str(params, AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE, val) < 0) {
        ret = -1;
    } else {
        ret = notify(params);
    }
    str_parms_destroy(params);
    return ret;
}
@@ -484,10 +487,13 @@ bool on_sndcard_state_update(sndcard_t *s)
    key = (is_cpe ?  "CPE_STATUS" :
          (is_slpi ? "SLPI_STATUS" :
                     "SND_CARD_STATUS"));
    if (str_parms_add_str(params, key, val) < 0)
        return -1;

    int ret = notify(params);
    int ret = 0;
    if (str_parms_add_str(params, key, val) < 0) {
        ret = -1;
    } else {
        ret = notify(params);
    }
    str_parms_destroy(params);
    return ret;
}