Fix big mistake in commit fd41f46ac6.

- When a mode is deleted, the name pointer is also free()'ed.
- This leaves other modes with an invalid pointer.
This commit is contained in:
Maarten Maathuis 2008-03-01 16:54:01 +01:00
parent ef60632e20
commit 8af2c39bcc

View File

@ -214,8 +214,15 @@ xf86DuplicateMode(DisplayModePtr pMode)
*pNew = *pMode;
pNew->next = NULL;
pNew->prev = NULL;
if (pNew->name == NULL)
/*
* It is important to copy the name explicitly.
* Otherwise a mode could reference an invalid piece of memory, after one of them runs free().
* This will lead to obscure problems, that you really don't want.
*/
if (pMode->name == NULL)
xf86SetModeDefaultName(pNew);
else
pNew->name = xnfstrdup(pMode->name);
return pNew;
}