Safe Learning of Uncertain Environments for Nonlinear Control-Affine Systems