diff options
author | Eric Anholt <eric@anholt.net> | 2006-12-18 15:57:08 -0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2006-12-18 15:57:08 -0800 |
commit | 8983845f91cacf8110c70121e0f5f293fe443e6d (patch) | |
tree | 77c1beab85578d8340297726edcd9fbe57b7457f /src | |
parent | fa4642048b183134544fc5ee47558446d27f6194 (diff) |
Fix crash in xf86SetScrnInfoModes when pScrn->modes ends up empty.
Diffstat (limited to 'src')
-rw-r--r-- | src/i830_xf86Crtc.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/i830_xf86Crtc.c b/src/i830_xf86Crtc.c index 51e6f1c7..bb6c8691 100644 --- a/src/i830_xf86Crtc.c +++ b/src/i830_xf86Crtc.c @@ -555,16 +555,20 @@ xf86SetScrnInfoModes (ScrnInfoPtr pScrn) for (mode = pScrn->modes; mode; mode = mode->next) if (xf86ModesEqual (mode, &crtc->desiredMode)) break; - - /* For some reason, pScrn->modes is circular, unlike the other mode lists. - * How great is that? - */ - for (last = pScrn->modes; last && last->next; last = last->next); - last->next = pScrn->modes; - pScrn->modes->prev = last; - if (mode) - while (pScrn->modes != mode) - pScrn->modes = pScrn->modes->next; + + if (pScrn->modes != NULL) { + /* For some reason, pScrn->modes is circular, unlike the other mode + * lists. How great is that? + */ + for (last = pScrn->modes; last && last->next; last = last->next) + ; + last->next = pScrn->modes; + pScrn->modes->prev = last; + if (mode) { + while (pScrn->modes != mode) + pScrn->modes = pScrn->modes->next; + } + } pScrn->currentMode = pScrn->modes; } |