shm: move shmsize verify before allocating the drawable.
Otherwise if the VERIFY_SHMSIZE macro fails we leak the drawables
we allocated earlier.
Noticed by coverity scan.
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 3439929c51
)
This commit is contained in:
parent
8e646ca985
commit
bdeab7863e
25
Xext/shm.c
25
Xext/shm.c
|
@ -834,6 +834,19 @@ ProcPanoramiXShmGetImage(ClientPtr client)
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (format == ZPixmap) {
|
||||||
|
widthBytesLine = PixmapBytePad(w, pDraw->depth);
|
||||||
|
length = widthBytesLine * h;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
widthBytesLine = PixmapBytePad(w, 1);
|
||||||
|
lenPer = widthBytesLine * h;
|
||||||
|
plane = ((Mask) 1) << (pDraw->depth - 1);
|
||||||
|
length = lenPer * Ones(planemask & (plane | (plane - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
|
||||||
|
|
||||||
drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr));
|
drawables = calloc(PanoramiXNumScreens, sizeof(DrawablePtr));
|
||||||
if (!drawables)
|
if (!drawables)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
@ -856,18 +869,6 @@ ProcPanoramiXShmGetImage(ClientPtr client)
|
||||||
.depth = pDraw->depth
|
.depth = pDraw->depth
|
||||||
};
|
};
|
||||||
|
|
||||||
if (format == ZPixmap) {
|
|
||||||
widthBytesLine = PixmapBytePad(w, pDraw->depth);
|
|
||||||
length = widthBytesLine * h;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
widthBytesLine = PixmapBytePad(w, 1);
|
|
||||||
lenPer = widthBytesLine * h;
|
|
||||||
plane = ((Mask) 1) << (pDraw->depth - 1);
|
|
||||||
length = lenPer * Ones(planemask & (plane | (plane - 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
VERIFY_SHMSIZE(shmdesc, stuff->offset, length, client);
|
|
||||||
xgi.size = length;
|
xgi.size = length;
|
||||||
|
|
||||||
if (length == 0) { /* nothing to do */
|
if (length == 0) { /* nothing to do */
|
||||||
|
|
Loading…
Reference in New Issue