Malfunctioning gun sends veteran to prison