Skip to content

Commit cc68309

Browse files
authored
Merge pull request #517 from bung87/fix-int-set
fix int set
2 parents 7aa356b + ccecb07 commit cc68309

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/pixie/fileformats/jpeg.nim

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,9 @@ proc decodeSOF0(state: var DecoderState) =
297297
if state.imageWidth == 0:
298298
failInvalid("image invalid 0 width")
299299

300-
let numComponents = state.readUint8().int
301-
if numComponents notin {1, 3}:
300+
let numComponentsU8 = state.readUint8()
301+
let numComponents = numComponentsU8.int
302+
if numComponentsU8 notin {1'u8, 3}:
302303
failInvalid("unsupported component count, must be 1 or 3")
303304

304305
len -= 6
@@ -315,7 +316,7 @@ proc decodeSOF0(state: var DecoderState) =
315316
if quantizationTableId > 3:
316317
failInvalid("invalid quantization table id")
317318

318-
if vertical notin {1, 2, 4} or horizontal notin {1, 2, 4}:
319+
if vertical notin {1'u8, 2, 4} or horizontal notin {1'u8, 2, 4}:
319320
failInvalid("invalid component scaling factor")
320321

321322
component.xScale = vertical.int
@@ -443,13 +444,13 @@ proc reset(state: var DecoderState) =
443444
proc decodeSOS(state: var DecoderState) =
444445
## Decode Start of Scan - header before the block data.
445446
var len = state.readUint16be() - 2
446-
447-
state.scanComponents = state.readUint8().int
447+
let scanComponentsU8 = state.readUint8()
448+
state.scanComponents = scanComponentsU8.int
448449

449450
if state.scanComponents > state.components.len:
450451
failInvalid("extra components")
451452

452-
if state.scanComponents notin {1, 3}:
453+
if scanComponentsU8 notin {1'u8, 3}:
453454
failInvalid("unsupported scan component count")
454455

455456
state.componentOrder.setLen(0)
@@ -878,7 +879,7 @@ proc checkRestart(state: var DecoderState) =
878879
if state.pos + 1 > state.len:
879880
failInvalid()
880881
if state.buffer[state.pos] != 0xFF or
881-
state.buffer[state.pos + 1] notin {0xD0 .. 0xD7}:
882+
state.buffer[state.pos + 1] notin 0xD0'u8 .. 0xD7'u8:
882883
failInvalid("did not get expected restart marker")
883884
state.pos += 2
884885
state.reset()

src/pixie/fileformats/qoi.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ proc decodeQoi*(data: string): Qoi {.raises: [PixieError].} =
6060
channels = data.readUint8(12)
6161
colorspace = data.readUint8(13)
6262

63-
if channels notin {3, 4} or colorspace notin {0, 1}:
63+
if channels notin {3'u8, 4} or colorspace notin {0'u8, 1}:
6464
raise newException(PixieError, "Invalid QOI header")
6565

6666
if width.int * height.int > uint32.high.int64:

0 commit comments

Comments
 (0)