drm_hwcomposer: Add safe guard for unknown connector type
There is potential possibility that new connector type will be added
into DRM and it won't be handled by drm_hwcomposer immediately so it's
better to be safe and report error via logcat than crash with
out-of-bounds.
Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
diff --git a/drm/drmconnector.cpp b/drm/drmconnector.cpp
index 2c0adda..7cde7cd 100644
--- a/drm/drmconnector.cpp
+++ b/drm/drmconnector.cpp
@@ -124,9 +124,14 @@
"SVIDEO", "LVDS", "Component", "DIN", "DP", "HDMI-A",
"HDMI-B", "TV", "eDP", "Virtual", "DSI"};
- std::ostringstream name_buf;
- name_buf << names[type_] << "-" << type_id_;
- return name_buf.str();
+ if (type_ < TYPES_COUNT) {
+ std::ostringstream name_buf;
+ name_buf << names[type_] << "-" << type_id_;
+ return name_buf.str();
+ } else {
+ ALOGE("Unknown type in connector %d, could not make his name", id_);
+ return "None";
+ }
}
int DrmConnector::UpdateModes() {