Fix infinite loop in GetShift
GetShift(mask) can be called with mask==0, leading to an infinite loop. Added a check for mask != 0 before entering the while loop.
GetShift(mask) can be called with mask==0, leading to an infinite loop. Added a check for mask != 0 before entering the while loop.