@@ -160,7 +160,7 @@ public enum CompactImageMapFormat {
160160 guard let char = iterator. next ( ) else {
161161 return nil
162162 }
163- if n > 0 && char == 0x2f {
163+ if base + n > stringBase! && ( char == 0x2f || char == 0x5c ) {
164164 let prefix = String ( decoding: resultBytes [ stringBase!..< base+ n] ,
165165 as: UTF8 . self)
166166 #if DEBUG_COMPACT_IMAGE_MAP
@@ -297,6 +297,10 @@ public enum CompactImageMapFormat {
297297 let acount = Int ( ( ( header >> 3 ) & 0x7 ) + 1 )
298298 let ecount = Int ( ( header & 0x7 ) + 1 )
299299
300+ #if DEBUG_COMPACT_IMAGE_MAP
301+ print ( " r = \( relative) , acount = \( acount) , ecount = \( ecount) " )
302+ #endif
303+
300304 // Now the base and end of text addresses
301305 guard let address = decodeAddress ( acount) else {
302306 return nil
@@ -315,11 +319,20 @@ public enum CompactImageMapFormat {
315319 }
316320 let endOfText = baseAddress &+ eotOffset
317321
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+
318327 // Next, get the build ID byte count
319328 guard let buildIdBytes = decodeCount ( ) else {
320329 return nil
321330 }
322331
332+ #if DEBUG_COMPACT_IMAGE_MAP
333+ print ( " buildIdBytes = \( buildIdBytes) " )
334+ #endif
335+
323336 // Read the build ID
324337 var buildId : [ UInt8 ] ? = nil
325338
@@ -335,6 +348,10 @@ public enum CompactImageMapFormat {
335348 }
336349 }
337350
351+ #if DEBUG_COMPACT_IMAGE_MAP
352+ print ( " buildId = \( buildId) " )
353+ #endif
354+
338355 // Decode the path
339356 let path = decodePath ( )
340357 let name : String ?
@@ -674,6 +691,9 @@ public enum CompactImageMapFormat {
674691
675692 // Add any new prefixes
676693 forEachPrefix ( of: remainingPath) { prefix in
694+ #if DEBUG_COMPACT_IMAGE_MAP
695+ print ( " defining \( nextCode) as \" \( prefix) \" " )
696+ #endif
677697 pathPrefixes. append ( ( nextCode, prefix) )
678698 nextCode += 1
679699 }
0 commit comments