shill: Do not run OnScanReply callback if it is null
For GSM, the current implementation of Cellular::Scan passes
callback that has not been bound to a method. OnScanReply tries
to run the callback, resulting in a seg fault. This change checks
for null before running the callback.
BUG=None
TEST=Ran all unit tests. Manual: Before logging in, do a mobile scan.
Verify that the scan completes and shill does not crash.
Change-Id: Ib6115892cf180bd7aeb237de8605dd89f81137b9
Reviewed-on: https://gerrit.chromium.org/gerrit/21384
Reviewed-by: Jason Glasgow <jglasgow@chromium.org>
Commit-Ready: Gary Morain <gmorain@chromium.org>
Tested-by: Gary Morain <gmorain@chromium.org>
diff --git a/cellular_capability_gsm.cc b/cellular_capability_gsm.cc
index 284c043..1715fec 100644
--- a/cellular_capability_gsm.cc
+++ b/cellular_capability_gsm.cc
@@ -640,7 +640,8 @@
}
cellular()->adaptor()->EmitStringmapsChanged(flimflam::kFoundNetworksProperty,
found_networks_);
- callback.Run(error);
+ if (!callback.is_null())
+ callback.Run(error);
}
Stringmap CellularCapabilityGSM::ParseScanResult(const GSMScanResult &result) {