File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -256,12 +256,18 @@ func compInfo(v uint16, sz int) Properties {
256
256
return p
257
257
}
258
258
// has decomposition
259
- h := decomps [v ]
259
+ h , ok := decompsVal (v )
260
+ if ! ok {
261
+ return Properties {size : uint8 (sz )}
262
+ }
260
263
f := (qcInfo (h & headerFlagsMask ) >> 2 ) | 0x4
261
264
p := Properties {size : uint8 (sz ), flags : f , index : v }
262
265
if v >= firstCCC {
263
266
v += uint16 (h & headerLenMask ) + 1
264
- c := decomps [v ]
267
+ c , ok := decompsVal (v )
268
+ if ! ok {
269
+ return Properties {size : uint8 (sz )}
270
+ }
265
271
p .tccc = c >> 2
266
272
p .flags |= qcInfo (c & 0x3 )
267
273
if v >= firstLeadingCCC {
@@ -272,8 +278,19 @@ func compInfo(v uint16, sz int) Properties {
272
278
p .index = 0
273
279
return p
274
280
}
275
- p .ccc = decomps [v + 1 ]
281
+ ccc , ok := decompsVal (v + 1 )
282
+ if ! ok {
283
+ return Properties {size : uint8 (sz )}
284
+ }
285
+ p .ccc = ccc
276
286
}
277
287
}
278
288
return p
279
289
}
290
+
291
+ func decompsVal (v uint16 ) (byte , bool ) {
292
+ if int (v ) >= len (decomps ) {
293
+ return 0 , false
294
+ }
295
+ return decomps [v ], true
296
+ }
You can’t perform that action at this time.
0 commit comments