From 2489dae9f7def788910eee5733931392df83a0d6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 15 Mar 2007 20:26:07 -0700 Subject: [PATCH] Correct ref counting of RRMode structures RRModes are referenced by the resource db, RROutput and RRCrtc structures. Ensure that the mode reference count is decremented each time a reference is lost from one of these sources. The missing destroys were in RRCrtcDestroyResource and RROutputDestroyResource, which only happen at server reset time, so modes would be unavailable in subsequent server generations. --- randr/rrcrtc.c | 2 ++ randr/rroutput.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 315dd6c08..ecf5bb251 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -361,6 +361,8 @@ RRCrtcDestroyResource (pointer value, XID pid) } if (crtc->gammaRed) xfree (crtc->gammaRed); + if (crtc->mode) + RRModeDestroy (crtc->mode); xfree (crtc); return 1; } diff --git a/randr/rroutput.c b/randr/rroutput.c index 6e95c9598..160071bcf 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -406,9 +406,12 @@ RROutputDestroyResource (pointer value, XID pid) } } } - /* XXX destroy all modes? */ if (output->modes) + { + for (m = 0; m < output->numModes; m++) + RRModeDestroy (output->modes[m]); xfree (output->modes); + } for (m = 0; m < output->numUserModes; m++) RRModeDestroy (output->userModes[m]);