@@ -160,7 +160,7 @@ public enum CompactImageMapFormat {
160
160
guard let char = iterator. next ( ) else {
161
161
return nil
162
162
}
163
- if n > 0 && char == 0x2f {
163
+ if base + n > stringBase! && ( char == 0x2f || char == 0x5c ) {
164
164
let prefix = String ( decoding: resultBytes [ stringBase!..< base+ n] ,
165
165
as: UTF8 . self)
166
166
#if DEBUG_COMPACT_IMAGE_MAP
@@ -297,6 +297,10 @@ public enum CompactImageMapFormat {
297
297
let acount = Int ( ( ( header >> 3 ) & 0x7 ) + 1 )
298
298
let ecount = Int ( ( header & 0x7 ) + 1 )
299
299
300
+ #if DEBUG_COMPACT_IMAGE_MAP
301
+ print ( " r = \( relative) , acount = \( acount) , ecount = \( ecount) " )
302
+ #endif
303
+
300
304
// Now the base and end of text addresses
301
305
guard let address = decodeAddress ( acount) else {
302
306
return nil
@@ -315,11 +319,20 @@ public enum CompactImageMapFormat {
315
319
}
316
320
let endOfText = baseAddress &+ eotOffset
317
321
322
+ #if DEBUG_COMPACT_IMAGE_MAP
323
+ print ( " address = \( hex ( address) ) , eotOffset = \( hex ( eotOffset) ) " )
324
+ print ( " baseAddress = \( hex ( baseAddress) ) , endOfText = \( hex ( endOfText) ) " )
325
+ #endif
326
+
318
327
// Next, get the build ID byte count
319
328
guard let buildIdBytes = decodeCount ( ) else {
320
329
return nil
321
330
}
322
331
332
+ #if DEBUG_COMPACT_IMAGE_MAP
333
+ print ( " buildIdBytes = \( buildIdBytes) " )
334
+ #endif
335
+
323
336
// Read the build ID
324
337
var buildId : [ UInt8 ] ? = nil
325
338
@@ -335,6 +348,10 @@ public enum CompactImageMapFormat {
335
348
}
336
349
}
337
350
351
+ #if DEBUG_COMPACT_IMAGE_MAP
352
+ print ( " buildId = \( buildId) " )
353
+ #endif
354
+
338
355
// Decode the path
339
356
let path = decodePath ( )
340
357
let name : String ?
@@ -674,6 +691,9 @@ public enum CompactImageMapFormat {
674
691
675
692
// Add any new prefixes
676
693
forEachPrefix ( of: remainingPath) { prefix in
694
+ #if DEBUG_COMPACT_IMAGE_MAP
695
+ print ( " defining \( nextCode) as \" \( prefix) \" " )
696
+ #endif
677
697
pathPrefixes. append ( ( nextCode, prefix) )
678
698
nextCode += 1
679
699
}
0 commit comments