Skip to content

Commit 021ec45

Browse files
authored
Merge pull request #57 from jazzychad/jc-negative-integer-crash-fix
Fix crash for negative uvcUnit integers (Issue #42)
2 parents afd68a5 + edb2d4f commit 021ec45

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

CameraController/UVC/Models/Controls/UVCControl.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class UVCControl {
3131
}
3232

3333
func getDataFor(type: UVCRequestCodes, length: Int) -> Int {
34+
35+
guard uvcUnit >= 0 else { return 0 }
36+
3437
var value: Int = 0
3538

3639
let requestType = USBmakebmRequestType(direction: kUSBIn, type: kUSBClass, recipient: kUSBInterface)
@@ -60,6 +63,9 @@ class UVCControl {
6063
}
6164

6265
func setData(value: Int, length: Int) -> Bool {
66+
67+
guard uvcUnit >= 0 else { return false }
68+
6369
var ref = value
6470

6571
let requestType = USBmakebmRequestType(direction: kUSBOut, type: kUSBClass, recipient: kUSBInterface)

0 commit comments

Comments
 (0)