Size xf86DefaultModes explicitly.
i.e., don't check for the end of the list by ->name == NULL, since that won't work now. Fix the consumers of xf86DefaultModes to use the new explicit size as well.
This commit is contained in:
parent
3fcb6445dc
commit
3bf7ff7032
|
@ -91,5 +91,6 @@ BEGIN {
|
|||
}
|
||||
|
||||
END {
|
||||
printf("\t{MODEPREFIX,0,0,0,0,0,0,0,0,0,0,0,0,MODESUFFIX}\n};\n")
|
||||
print "};"
|
||||
printf "const int xf86NumDefaultModes = sizeof(xf86NumDefaultModes) / sizeof(DisplayModeRec);"
|
||||
}
|
||||
|
|
|
@ -2420,28 +2420,16 @@ addDefaultModes(MonPtr monitorp)
|
|||
DisplayModePtr last = monitorp->Last;
|
||||
int i = 0;
|
||||
|
||||
while (xf86DefaultModes[i].name != NULL)
|
||||
{
|
||||
if ( ! modeIsPresent(xf86DefaultModes[i].name,monitorp) )
|
||||
do
|
||||
for (i = 0; i < xf86NumDefaultModes; i++)
|
||||
{
|
||||
mode = xf86DuplicateMode(&xf86DefaultModes[i]);
|
||||
if( last ) {
|
||||
mode->prev = last;
|
||||
last->next = mode;
|
||||
}
|
||||
else {
|
||||
/* this is the first mode */
|
||||
monitorp->Modes = mode;
|
||||
mode->prev = NULL;
|
||||
}
|
||||
if (!modeIsPresent(mode, monitorp))
|
||||
{
|
||||
monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
|
||||
last = mode;
|
||||
i++;
|
||||
} else {
|
||||
xfree(mode);
|
||||
}
|
||||
while((xf86DefaultModes[i].name != NULL) &&
|
||||
(!strcmp(xf86DefaultModes[i].name,xf86DefaultModes[i-1].name)));
|
||||
else
|
||||
i++;
|
||||
}
|
||||
monitorp->Last = last;
|
||||
|
||||
|
|
|
@ -154,6 +154,7 @@ Bool xf86PathIsSafe(const char *path);
|
|||
/* xf86DefaultModes */
|
||||
|
||||
extern const DisplayModeRec xf86DefaultModes[];
|
||||
extern const int xf86NumDefaultModes;
|
||||
|
||||
/* xf86DoProbe.c */
|
||||
void DoProbe(void);
|
||||
|
|
|
@ -214,11 +214,7 @@ xf86DuplicateMode(DisplayModePtr pMode)
|
|||
*pNew = *pMode;
|
||||
pNew->next = NULL;
|
||||
pNew->prev = 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
|
||||
|
@ -667,7 +663,7 @@ xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed)
|
|||
DisplayModePtr head = NULL, prev = NULL, mode;
|
||||
int i;
|
||||
|
||||
for (i = 0; xf86DefaultModes[i].name != NULL; i++)
|
||||
for (i = 0; i < xf86NumDefaultModes; i++)
|
||||
{
|
||||
DisplayModePtr defMode = &xf86DefaultModes[i];
|
||||
|
||||
|
@ -676,23 +672,9 @@ xf86GetDefaultModes (Bool interlaceAllowed, Bool doubleScanAllowed)
|
|||
if (!doubleScanAllowed && (defMode->Flags & V_DBLSCAN))
|
||||
continue;
|
||||
|
||||
mode = xalloc(sizeof(DisplayModeRec));
|
||||
if (!mode)
|
||||
continue;
|
||||
memcpy(mode,&xf86DefaultModes[i],sizeof(DisplayModeRec));
|
||||
mode->name = xstrdup(xf86DefaultModes[i].name);
|
||||
if (!mode->name)
|
||||
{
|
||||
xfree (mode);
|
||||
continue;
|
||||
}
|
||||
mode->prev = prev;
|
||||
mode->next = NULL;
|
||||
if (prev)
|
||||
prev->next = mode;
|
||||
else
|
||||
head = mode;
|
||||
prev = mode;
|
||||
mode = xf86DuplicateMode(defMode);
|
||||
|
||||
head = xf86ModesAdd(head, mode);
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue