The critical layer for internal gravity waves in a shear flow