[PATCH 2/2] xfree86: prune duplicate monitor modes.

alexdeucher at gmail.com alexdeucher at gmail.com
Mon Jun 17 09:39:21 PDT 2013


From: Leo Liu <leo.liu at amd.com>

same monitor modes added causing memory leak
when looping xrandr prop.

Signed-off-by: Leo Liu <leo.liu at amd.com>
---
 hw/xfree86/modes/xf86EdidModes.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 4ee862d..261780b 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -1143,6 +1143,27 @@ handle_detailed_monset(struct detailed_monitor_section *det_mon, void *data)
     }
 }
 
+static void
+xf86PruneDuplicateMonitorModes(MonPtr Monitor)
+{
+    DisplayModePtr master, clone, next;
+
+    for (master = Monitor->Modes;
+         master && master != Monitor->Last;
+         master = master->next) {
+        for (clone = master->next;
+             clone && clone != Monitor->Modes;
+             clone = next) {
+            next = clone->next;
+            if (xf86ModesEqual (master, clone)) {
+                if (Monitor->Last == clone)
+                    Monitor->Last = clone->prev;
+                xf86DeleteMode (&Monitor->Modes, clone);
+            }
+        }
+    }
+}
+
 /*
  * Fill out MonPtr with xf86MonPtr information.
  */
@@ -1204,5 +1225,6 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
             Monitor->Modes = Modes;
             Monitor->Last = Mode;
         }
+        xf86PruneDuplicateMonitorModes(Monitor);
     }
 }
-- 
1.7.9.5



More information about the xorg-devel mailing list