fix warning: dereference of a null pointer
This fixes a warning: Access to field 'mPlaybackFormats' results
in a dereference of a null pointer (loaded from field 'mDeviceInfo')
[clang-analyzer-core.NullDereference]
Bug: None
Test: Static analyzer no longer complains, bullhead still boots with no
apparent issues.
Change-Id: I71ce486c667441d9b90ef63c2df8d23d70254639
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index bd89a51..5f34843 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -263,19 +263,20 @@
}
void MtpDevice::print() {
- if (mDeviceInfo) {
- mDeviceInfo->print();
+ if (!mDeviceInfo)
+ return;
- if (mDeviceInfo->mDeviceProperties) {
- ALOGI("***** DEVICE PROPERTIES *****\n");
- int count = mDeviceInfo->mDeviceProperties->size();
- for (int i = 0; i < count; i++) {
- MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
- MtpProperty* property = getDevicePropDesc(propCode);
- if (property) {
- property->print();
- delete property;
- }
+ mDeviceInfo->print();
+
+ if (mDeviceInfo->mDeviceProperties) {
+ ALOGI("***** DEVICE PROPERTIES *****\n");
+ int count = mDeviceInfo->mDeviceProperties->size();
+ for (int i = 0; i < count; i++) {
+ MtpDeviceProperty propCode = (*mDeviceInfo->mDeviceProperties)[i];
+ MtpProperty* property = getDevicePropDesc(propCode);
+ if (property) {
+ property->print();
+ delete property;
}
}
}