Skip to content
  • Jamey Sharp's avatar
    Device init: Don't crash when CreateGC fails. · b9f48d60
    Jamey Sharp authored and Keith Packard's avatar Keith Packard committed
    
    
    ActivateDevice was ignoring errors from DeviceCursorInitialize, so
    cursor-related calls failed later. Jeremy Huddleston saw that crash in
    miPointerConstrainCursor, while with Xvfb I saw it in
    miSpriteRealizeCursor.
    
    miDCDeviceCleanup frees any non-NULL GCs. miDCDeviceInitialize calls
    Cleanup on any failure, but if it failed early then some of the pointers
    in the miDCBufferPtr were garbage. Switch from malloc to calloc to
    ensure everything's initialized safely first.
    
    With these two fixes, if CreateGC fails then the server gracefully fails
    in FatalError instead of segfaulting.
    
    Signed-off-by: default avatarJamey Sharp <jamey@minilop.net>
    Cc: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
    b9f48d60