mirror of
https://github.com/X11Libre/xserver.git
synced 2026-11-03 03:24:39 +00:00
randr: always realloc crtcs and outputs
When the last crtc (resp. output) is destroyed, the rrScrPriv crtcs (resp. outputs) fields do not get cleared, which can lead to a situation where the private's numCrtcs (resp. numOutputs) field is zero, but the associated memory is still allocated. Just checking if numCrtcs (resp. numOutputs) is zero is thus not a good criteria to determine whetehr to use a realloc or a malloc. Since crtcs (resp. outputs) are NULL-initialized anyway, relying on numCrtcs (resp. numOutputs) is actually unnecessary, because reallocation of a NULL ptr is equivalent to a malloc anyway. Therefore, just use realloc() unconditionally, and ensure that the fields are properly initialized. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
This commit is contained in:
parent
fb5ee77b91
commit
16381d186e
2 changed files with 6 additions and 12 deletions
|
|
@ -71,13 +71,10 @@ RROutputCreate(ScreenPtr pScreen,
|
|||
|
||||
pScrPriv = rrGetScrPriv(pScreen);
|
||||
|
||||
if (pScrPriv->numOutputs)
|
||||
outputs = reallocarray(pScrPriv->outputs,
|
||||
pScrPriv->numOutputs + 1, sizeof(RROutputPtr));
|
||||
else
|
||||
outputs = malloc(sizeof(RROutputPtr));
|
||||
outputs = reallocarray(pScrPriv->outputs,
|
||||
pScrPriv->numOutputs + 1, sizeof(RROutputPtr));
|
||||
if (!outputs)
|
||||
return FALSE;
|
||||
return NULL;
|
||||
|
||||
pScrPriv->outputs = outputs;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue