When node is NULL when calling getparent() et al. they return NULL but performing arithmetic on the NULL pointer is undefined. Check if 'node' or 'header' is NULL and skip the adjustment.