Commit fdc79fe7 authored by Michel Dänzer's avatar Michel Dänzer Committed by Adam Jackson

edid: Prune duplicates after adding modes from DDC

Multiple calls to xf86EdidMonitorSet (which can be triggered e.g. by
running xrandr) would potentially keep adding the same modes, causing
the Monitor->Modes list to keep growing larger and using up more memory.

Fix this by calling xf86PruneDuplicateModes after adding the modes
returned by xf86DDCGetModes. This makes sure there's only one instance
of each unique mode in the list.

* Replace semicolon with {} for empty for loop (Emil Velikov)
* Slightly tweak commit log to avoid minor inaccuracy about what
  xf86PruneDuplicateModes does

Bugzilla: Michel Dänzer's avatarMichel Dänzer <>
Reviewed-by: Emil Velikov's avatarEmil Velikov <>
parent 4e76c271
......@@ -1198,21 +1198,19 @@ xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
if (!Monitor->nHsync || !Monitor->nVrefresh)
DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
/* look for last Mode */
Mode = Modes;
while (Mode->next)
Mode = Mode->next;
/* add to MonPtr */
if (Monitor->Modes) {
Monitor->Last->next = Modes;
Modes->prev = Monitor->Last;
Monitor->Last = Mode;
else {
Monitor->Modes = Modes;
Monitor->Last = Mode;
/* Update pointer to last mode */
for (Mode = Monitor->Modes; Mode && Mode->next; Mode = Mode->next) {}
Monitor->Last = Mode;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment