From 7eafab7304ccac9bd95e92d479bea94695ec850d Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Wed, 11 Dec 2019 18:37:52 +0100 Subject: [PATCH] [platforms/drm] Return when property found When initializing a property we loop through the drmModeObjectProperties object and search for the property by its name. Once found we create the Property object and there should be not another one with the same name afterwards. In any case we would leak memory. Therefore just directly return once the property was found. This gives us the added benefit that we can put out a warning in case the property was not found in the loop, what should not happen with the properties we use. --- plugins/platforms/drm/drm_object.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/platforms/drm/drm_object.cpp b/plugins/platforms/drm/drm_object.cpp index cfecd7d4b6..2aff328ff3 100644 --- a/plugins/platforms/drm/drm_object.cpp +++ b/plugins/platforms/drm/drm_object.cpp @@ -61,8 +61,10 @@ void DrmObject::initProp(int n, drmModeObjectProperties *properties, QVectorname << "' (id " << prop->prop_id << "): " << properties->prop_values[i]; m_props[n] = new Property(prop.data(), properties->prop_values[i], enumNames); + return; } } + qCWarning(KWIN_DRM) << "Initializing property" << m_propsNames[n] << "failed"; } bool DrmObject::atomicPopulate(drmModeAtomicReq *req) const