diff options
author | Matthieu Herrb <matthieu.herrb@laas.fr> | 2021-02-27 11:30:18 +0100 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-03-08 20:32:54 +0000 |
commit | b2d96b5cd459963a9587ee9c86afc9266ba3d02b (patch) | |
tree | aa49ab3b4e1b5305b09c831b0ceec1dfb6b66721 | |
parent | 15a413e11d186a9206a39a9b2fe4b72c065d5918 (diff) |
Avoid sequences of malloc(0) / free() by checking the length.
This has an impact on heap fragmentation.
Signed-off-by: Matthieu Herrb <matthieu.herrb@laas.fr>
-rw-r--r-- | mi/miexpose.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/mi/miexpose.c b/mi/miexpose.c index d84bb6a98..e54b18b30 100644 --- a/mi/miexpose.c +++ b/mi/miexpose.c @@ -404,7 +404,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 @@ -508,7 +508,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; |