dri: report failed memory allocation
ProcXF86DRIGetDrawableInfo() should report failed memory allocation instead of pretending everything's okay. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1797>
This commit is contained in:
parent
2539ddae50
commit
94d942267a
|
@ -425,28 +425,25 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
|
||||||
/* Clip cliprects to screen dimensions (redirected windows) */
|
/* Clip cliprects to screen dimensions (redirected windows) */
|
||||||
pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t));
|
pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t));
|
||||||
|
|
||||||
if (pClippedRects) {
|
if (!pClippedRects)
|
||||||
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
|
return BadAlloc;
|
||||||
int i, j;
|
|
||||||
|
|
||||||
for (i = 0, j = 0; i < rep.numClipRects; i++) {
|
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
|
||||||
pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
|
int i, j;
|
||||||
pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
|
|
||||||
pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
|
|
||||||
pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
|
|
||||||
|
|
||||||
if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
|
for (i = 0, j = 0; i < rep.numClipRects; i++) {
|
||||||
pClippedRects[j].y1 < pClippedRects[j].y2) {
|
pClippedRects[j].x1 = max(pClipRects[i].x1, 0);
|
||||||
j++;
|
pClippedRects[j].y1 = max(pClipRects[i].y1, 0);
|
||||||
}
|
pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width);
|
||||||
|
pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height);
|
||||||
|
|
||||||
|
if (pClippedRects[j].x1 < pClippedRects[j].x2 &&
|
||||||
|
pClippedRects[j].y1 < pClippedRects[j].y2) {
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rep.numClipRects = j;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rep.numClipRects = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rep.numClipRects = j;
|
||||||
rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
|
rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue