diff --git a/src/core/libs/gnss_sdr_supl_client.cc b/src/core/libs/gnss_sdr_supl_client.cc index 665493db8..a7d374fdc 100644 --- a/src/core/libs/gnss_sdr_supl_client.cc +++ b/src/core/libs/gnss_sdr_supl_client.cc @@ -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;