mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-07-03 18:42:56 +00:00
Cleaning for safety
To avoid memory leaks, make sure the supl_ctx_t data structure is initialized and cleaned as well as the connection is closed with the server. Signed-off-by: Carles Fernandez <carles.fernandez@gmail.com>
This commit is contained in:
parent
6804f931ed
commit
0fbea1a25c
@ -147,6 +147,7 @@ int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_
|
|||||||
mns = i_mns;
|
mns = i_mns;
|
||||||
lac = i_lac;
|
lac = i_lac;
|
||||||
ci = i_ci;
|
ci = i_ci;
|
||||||
|
if (supl_ctx_new(&ctx)) {} // clean it before using
|
||||||
supl_set_gsm_cell(&ctx, mcc, mns, lac, ci);
|
supl_set_gsm_cell(&ctx, mcc, mns, lac, ci);
|
||||||
|
|
||||||
// PERFORM SUPL COMMUNICATION
|
// PERFORM SUPL COMMUNICATION
|
||||||
@ -161,6 +162,15 @@ int gnss_sdr_supl_client::get_assistance(int i_mcc, int i_mns, int i_lac, int i_
|
|||||||
if (err == 0)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
read_supl_data();
|
read_supl_data();
|
||||||
|
if (supl_ctx_free(&ctx)) {} // clean it up before leaving
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* If supl_get_assist() fails, the connection remains open
|
||||||
|
* and the memory/files are not released.
|
||||||
|
*/
|
||||||
|
supl_close(&ctx);
|
||||||
}
|
}
|
||||||
delete [] cstr;
|
delete [] cstr;
|
||||||
return err;
|
return err;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user