Protection for ROOT-6454 (copied from 5.34 patches)