diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2021-03-13 09:43:59 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2021-03-13 09:43:59 +0000 |
commit | 33917e68840ce1292995889870c3e0ed0e073218 (patch) | |
tree | cf8177dbadaeae6b291f5c62c25b7518f9cf91c7 /xserver/mi/miexpose.c | |
parent | 9029a53279b68b52d4b54446642ead1415aba534 (diff) |
Avoid sequences of malloc(0) / free() by checking the length.
b2d96b5cd459963a9587ee9c86afc9266ba3d02b in xserver git
originally from deraadt@
Diffstat (limited to 'xserver/mi/miexpose.c')
-rw-r--r-- | xserver/mi/miexpose.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/xserver/mi/miexpose.c b/xserver/mi/miexpose.c index c34530c34..610829f98 100644 --- a/xserver/mi/miexpose.c +++ b/xserver/mi/miexpose.c @@ -411,7 +411,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) int i; BoxPtr pbox; xRectangle *prect; - int numRects; + int numRects, regionnumrects; /* * Distance from screen to destination drawable, use this @@ -515,7 +515,10 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin; } - prect = xallocarray(RegionNumRects(prgn), sizeof(xRectangle)); + regionnumrects = RegionNumRects(prgn); + if (regionnumrects == 0) + return; + prect = xallocarray(regionnumrects, sizeof(xRectangle)); if (!prect) return; |