Skip to content

Commit 2e049ce

Browse files
authored
Merge pull request #8019 from jarvte/fix_crash_in_close_cellularnetwork
Cellular: fixed crash when closing CellularNetwork via CellularDevice.
2 parents c503ded + ed7606b commit 2e049ce

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

features/cellular/framework/AT/AT_CellularBase.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ namespace mbed {
2929
class AT_CellularBase {
3030
public:
3131
AT_CellularBase(ATHandler &at);
32-
3332
/** Getter for at handler. Common method for all AT-classes.
3433
*
3534
* @return reference to ATHandler

features/cellular/framework/AT/AT_CellularDevice.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ void AT_CellularDevice::close_network()
207207
if (_network) {
208208
_network_ref_count--;
209209
if (_network_ref_count == 0) {
210-
release_at_handler(&_network->get_at_handler());
210+
ATHandler *atHandler = &_network->get_at_handler();
211211
delete _network;
212212
_network = NULL;
213+
release_at_handler(atHandler);
213214
}
214215
}
215216
}
@@ -219,9 +220,10 @@ void AT_CellularDevice::close_sms()
219220
if (_sms) {
220221
_sms_ref_count--;
221222
if (_sms_ref_count == 0) {
222-
release_at_handler(&_sms->get_at_handler());
223+
ATHandler *atHandler = &_sms->get_at_handler();
223224
delete _sms;
224225
_sms = NULL;
226+
release_at_handler(atHandler);
225227
}
226228
}
227229
}
@@ -231,9 +233,10 @@ void AT_CellularDevice::close_power()
231233
if (_power) {
232234
_power_ref_count--;
233235
if (_power_ref_count == 0) {
234-
release_at_handler(&_power->get_at_handler());
236+
ATHandler *atHandler = &_power->get_at_handler();
235237
delete _power;
236238
_power = NULL;
239+
release_at_handler(atHandler);
237240
}
238241
}
239242
}
@@ -243,9 +246,10 @@ void AT_CellularDevice::close_sim()
243246
if (_sim) {
244247
_sim_ref_count--;
245248
if (_sim_ref_count == 0) {
246-
release_at_handler(&_sim->get_at_handler());
249+
ATHandler *atHandler = &_sim->get_at_handler();
247250
delete _sim;
248251
_sim = NULL;
252+
release_at_handler(atHandler);
249253
}
250254
}
251255
}
@@ -255,9 +259,10 @@ void AT_CellularDevice::close_information()
255259
if (_information) {
256260
_info_ref_count--;
257261
if (_info_ref_count == 0) {
258-
release_at_handler(&_information->get_at_handler());
262+
ATHandler *atHandler = &_information->get_at_handler();
259263
delete _information;
260264
_information = NULL;
265+
release_at_handler(atHandler);
261266
}
262267
}
263268
}

0 commit comments

Comments
 (0)