Missing check for NULL pointer corrected.