Copy from master fix for ROOT-6664