fix nil dereferencing

This commit is contained in:
Michele Balistreri 2022-09-06 09:02:05 +02:00
parent 059bc140ce
commit e43cb0f06a
1 changed files with 2 additions and 2 deletions

View File

@ -198,7 +198,7 @@ func (cs *CommandSet) VerifyPIN(pin string) error {
cmd := NewCommandVerifyPIN(pin)
resp, err := cs.sc.Send(cmd)
if err = cs.checkOK(resp, err); err != nil {
if resp.Sw&0x63C0 == 0x63C0 {
if resp != nil && ((resp.Sw & 0x63C0) == 0x63C0) {
remainingAttempts := resp.Sw & 0x000F
return &WrongPINError{
RemainingAttempts: int(remainingAttempts),
@ -220,7 +220,7 @@ func (cs *CommandSet) UnblockPIN(puk string, newPIN string) error {
cmd := NewCommandUnblockPIN(puk, newPIN)
resp, err := cs.sc.Send(cmd)
if err = cs.checkOK(resp, err); err != nil {
if resp.Sw&0x63C0 == 0x63C0 {
if resp != nil && ((resp.Sw & 0x63C0) == 0x63C0) {
remainingAttempts := resp.Sw & 0x000F
return &WrongPUKError{
RemainingAttempts: int(remainingAttempts),