diff options
author | Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> | 2019-11-25 19:17:53 +0200 |
---|---|---|
committer | Roman Kovalivskyi <roman.kovalivskyi@globallogic.com> | 2019-11-28 13:01:15 +0000 |
commit | d6a6e6eadd783365013fdc493c00994054f3e6aa (patch) | |
tree | a6e2203d7986c5382d64f1f7d2e6d39641ba5308 | |
parent | e606a62848a58dc0f8b0881843d7122d986a4f30 (diff) |
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>
-rw-r--r-- | drm/drmconnector.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
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 @@ std::string DrmConnector::name() const { "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() { |