From 6acbfab33133a92dbd7f128284d26f94bfeb1af2 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sun, 10 Dec 2017 23:57:35 +0100 Subject: reduce usage of uninitialised bytes as reported by valgrind --- nx-X11/programs/Xserver/mi/miexpose.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'nx-X11/programs/Xserver/mi') diff --git a/nx-X11/programs/Xserver/mi/miexpose.c b/nx-X11/programs/Xserver/mi/miexpose.c index c39221000..db7fdf010 100644 --- a/nx-X11/programs/Xserver/mi/miexpose.c +++ b/nx-X11/programs/Xserver/mi/miexpose.c @@ -395,7 +395,7 @@ miSendGraphicsExpose (client, pRgn, drawable, major, minor) numRects = RegionNumRects(pRgn); pBox = RegionRects(pRgn); - if(!(pEvent = (xEvent *)malloc(numRects * sizeof(xEvent)))) + if(!(pEvent = (xEvent *)calloc(numRects, sizeof(xEvent)))) return; pe = pEvent; @@ -417,8 +417,7 @@ miSendGraphicsExpose (client, pRgn, drawable, major, minor) } else { - xEvent event; - memset(&event, 0, sizeof(xEvent)); + xEvent event = {0}; event.u.u.type = NoExpose; event.u.noExposure.drawable = drawable; event.u.noExposure.majorEvent = major; @@ -442,9 +441,8 @@ miSendExposures(pWin, pRgn, dx, dy) pBox = RegionRects(pRgn); numRects = RegionNumRects(pRgn); - if(!(pEvent = (xEvent *) malloc(numRects * sizeof(xEvent)))) + if(!(pEvent = (xEvent *) calloc(numRects, sizeof(xEvent)))) return; - memset(pEvent, 0, numRects * sizeof(xEvent)); for (i=numRects, pe = pEvent; --i >= 0; pe++, pBox++) { @@ -658,7 +656,7 @@ int what; BITS32 gcmask, index, mask; RegionRec prgnWin; DDXPointRec oldCorner; - BoxRec box; + BoxRec box = {0}; WindowPtr pBgWin; GCPtr pGC; register int i; @@ -705,8 +703,7 @@ int what; } } - prect = (xRectangle *)malloc(RegionNumRects(prgn) * - sizeof(xRectangle)); + prect = (xRectangle *)calloc(RegionNumRects(prgn), sizeof(xRectangle)); if (!prect) return; @@ -892,8 +889,7 @@ miClearDrawable(pDraw, pGC) { XID fg = pGC->fgPixel; XID bg = pGC->bgPixel; - xRectangle rect; - + xRectangle rect = {0}; rect.x = 0; rect.y = 0; rect.width = pDraw->width; -- cgit v1.2.3