@@ -176,14 +176,14 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb,
176176 int nscr ;
177177 ScreenPtr pscr ;
178178
179- pCurs = (CursorPtr )malloc ( sizeof ( CursorRec ) + sizeof ( CursorBits ) );
179+ pCurs = (CursorPtr ) calloc ( CURSOR_REC_SIZE + CURSOR_BITS_SIZE , 1 );
180180 if (!pCurs )
181181 {
182182 free (psrcbits );
183183 free (pmaskbits );
184184 return (CursorPtr )NULL ;
185185 }
186- bits = (CursorBitsPtr )((char * )pCurs + sizeof ( CursorRec ) );
186+ bits = (CursorBitsPtr )((char * )pCurs + CURSOR_REC_SIZE );
187187 dixInitPrivates (pCurs , pCurs + 1 , PRIVATE_CURSOR );
188188 dixInitPrivates (bits , bits + 1 , PRIVATE_CURSOR_BITS );
189189
@@ -298,7 +298,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
298298 }
299299 if (pShare )
300300 {
301- pCurs = (CursorPtr )malloc ( sizeof ( CursorRec ) );
301+ pCurs = (CursorPtr ) calloc ( CURSOR_REC_SIZE , 1 );
302302 if (!pCurs )
303303 return BadAlloc ;
304304 dixInitPrivates (pCurs , pCurs + 1 , PRIVATE_CURSOR );
@@ -341,17 +341,17 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
341341 }
342342 if (sourcefont != maskfont )
343343 {
344- pCurs = (CursorPtr )malloc ( sizeof ( CursorRec ) + sizeof ( CursorBits ) );
344+ pCurs = (CursorPtr ) calloc ( CURSOR_REC_SIZE + CURSOR_BITS_SIZE , 1 );
345345 if (pCurs )
346- bits = (CursorBitsPtr )((char * )pCurs + sizeof ( CursorRec ) );
346+ bits = (CursorBitsPtr ) ((char * ) pCurs + CURSOR_REC_SIZE );
347347 else
348348 bits = (CursorBitsPtr )NULL ;
349349 }
350350 else
351351 {
352- pCurs = (CursorPtr )malloc ( sizeof ( CursorRec ) );
352+ pCurs = (CursorPtr ) calloc ( CURSOR_REC_SIZE , 1 );
353353 if (pCurs )
354- bits = (CursorBitsPtr )malloc ( sizeof ( CursorBits ) );
354+ bits = (CursorBitsPtr ) calloc ( CURSOR_BITS_SIZE , 1 );
355355 else
356356 bits = (CursorBitsPtr )NULL ;
357357 }
0 commit comments