From fb5b3b956f03d5b8a78e53baa8362291158d8998 Mon Sep 17 00:00:00 2001 From: Stuart Bennett Date: Thu, 26 Jun 2008 14:44:45 +0100 Subject: [PATCH] randr12: fix mode detection for when screen size changes also some mem leaks --- src/nv_output.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nv_output.c b/src/nv_output.c index cca78bf..e6a6be1 100644 --- a/src/nv_output.c +++ b/src/nv_output.c @@ -499,6 +499,7 @@ nv_output_get_modes(xf86OutputPtr output, xf86MonPtr mon) int i; DisplayModePtr mode; + nv_output->fpHeight = nv_output->fpWidth = 0; for (i = 0; i < DET_TIMINGS; i++) { /* We only look at detailed timings atm */ if (mon->det_mon[i].type != DT) @@ -514,10 +515,11 @@ nv_output_get_modes(xf86OutputPtr output, xf86MonPtr mon) return NULL; } - if (nv_output->native_mode) + if (nv_output->native_mode) { xfree(nv_output->native_mode); + nv_output->native_mode = NULL; + } - /* Prefer ddc modes. */ for (mode = ddc_modes; mode != NULL; mode = mode->next) { if (mode->HDisplay == nv_output->fpWidth && mode->VDisplay == nv_output->fpHeight) { @@ -528,6 +530,8 @@ nv_output_get_modes(xf86OutputPtr output, xf86MonPtr mon) } /* Find the highest refresh mode otherwise. */ if (!nv_output->native_mode || (mode->VRefresh > nv_output->native_mode->VRefresh)) { + if (nv_output->native_mode) + xfree(nv_output->native_mode); mode->type |= M_T_PREFERRED; nv_output->native_mode = xf86DuplicateMode(mode); } @@ -864,6 +868,8 @@ nv_lvds_output_get_modes(xf86OutputPtr output) xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Panel size is %u x %u\n", nv_output->fpWidth, nv_output->fpHeight); + if (nv_output->native_mode) + xfree(nv_output->native_mode); nv_output->native_mode = xf86DuplicateMode(pNv->VBIOS.fp.native_mode); return xf86DuplicateMode(pNv->VBIOS.fp.native_mode); -- 1.5.4.4