Skip to content
  • Alan Coopersmith's avatar
    Handle failure to create counter in init_system_idle_counter · f4a9332a
    Alan Coopersmith authored
    
    
    Check for NULL pointer (which can be returned for multiple reasons)
    before trying to dereference it to add privates.   To avoid memory leak
    in error path, delay malloc of privates until we're ready to add them.
    
    In case we do return NULL up through SyncInitDeviceIdleTime, handle the
    possibility of getting NULL passed back down to SyncRemoveDeviceIdleTime.
    
    As reported by parfait 1.1:
    Error: Null pointer dereference (CWE 476)
       Read from null pointer 'idle_time_counter'
            at line 2764 of xserver/Xext/sync.c in function 'init_system_idle_counter'.
              Function 'SyncCreateSystemCounter' may return constant 'NULL' at line 952, called at line 2756.
              Null pointer introduced at line 952 in function 'SyncCreateSystemCounter'.
    
    Signed-off-by: default avatarAlan Coopersmith <alan.coopersmith@oracle.com>
    Reviewed-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
    f4a9332a