1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-05 10:17:03 +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:
Leonardo Tonetto 2014-05-13 15:02:45 +02:00 committed by Carles Fernandez
parent 6804f931ed
commit 0fbea1a25c

View File

@ -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;
lac = i_lac;
ci = i_ci;
if (supl_ctx_new(&ctx)) {} // clean it before using
supl_set_gsm_cell(&ctx, mcc, mns, lac, ci);
// 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)
{
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;
return err;