Skip to content

Commit 39fb290

Browse files
committed
Avoid negative _claims
1 parent 063f505 commit 39fb290

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/helpers/RefCountedDigitalPin.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ class RefCountedDigitalPin {
2222
}
2323

2424
void release() {
25+
if (_claims == 0) return; // avoid negative _claims
26+
27+
_claims--;
2528
if (_claims == 0) {
2629
digitalWrite(_pin, !_active);
27-
} else {
28-
_claims--;
2930
}
3031
}
3132
};

0 commit comments

Comments
 (0)