diff options
author | Noralf Trønnes <noralf@tronnes.org> | 2021-03-14 18:36:10 +0000 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2021-10-26 17:44:54 +0000 |
commit | 9cf95baaf343e015ac2b52685321a2d9a4b05637 (patch) | |
tree | c71bd0e012859ef382fd88489673c4eadd568102 /video/out/drm_common.c | |
parent | 78cfeee2b93830f2988508a653b508336147b79d (diff) | |
download | mpv-9cf95baaf343e015ac2b52685321a2d9a4b05637.tar.bz2 mpv-9cf95baaf343e015ac2b52685321a2d9a4b05637.tar.xz |
drm_common: support unknown connector types
Avoid 'Segmentation fault' by using the connector type name UNKNOWN if
the connector type is not known to mpv.
Diffstat (limited to 'video/out/drm_common.c')
-rw-r--r-- | video/out/drm_common.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/video/out/drm_common.c b/video/out/drm_common.c index b631ee656c..a8db0a0d96 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -146,8 +146,15 @@ struct drm_mode_spec { static void get_connector_name(const drmModeConnector *connector, char ret[MAX_CONNECTOR_NAME_LEN]) { - snprintf(ret, MAX_CONNECTOR_NAME_LEN, "%s-%d", - connector_names[connector->connector_type], + const char *type_name; + + if (connector->connector_type < MP_ARRAY_SIZE(connector_names)) { + type_name = connector_names[connector->connector_type]; + } else { + type_name = "UNKNOWN"; + } + + snprintf(ret, MAX_CONNECTOR_NAME_LEN, "%s-%d", type_name, connector->connector_type_id); } |