Skip to content

Commit e3bea0a

Browse files
authored
fix #7
1 parent 4e6e1f6 commit e3bea0a

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

fico.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -464,22 +464,22 @@ func parseDir(b []byte, p int, prefix string, addr uint32) []*resource {
464464
// Iterate over all entries in the current directory record
465465
for i := 0; i < n; i++ {
466466
o := 8*i + p + 16
467-
name := int(le.Uint32(b[o : o+4]))
468-
offsetToData := int(le.Uint32(b[o+4 : o+8]))
467+
name := le.Uint32(b[o : o+4])
468+
offsetToData := le.Uint32(b[o+4 : o+8])
469469
path := prefix
470-
if name < 0 { // Named entry if the high bit is set in the name
471-
dirLen := name & 0x7FFFFFFF
472-
length := int(le.Uint16(b[dirLen : dirLen+2]))
470+
if name&0x80000000 > 0 { // Named entry if the high bit is set in the name
471+
dirStr := int(name & 0x7FFFFFFF)
472+
length := int(le.Uint16(b[dirStr : dirStr+2]))
473473
resID := make([]uint16, length)
474-
binary.Read(bytes.NewReader(b[dirLen+2:dirLen+2+length<<1]), le, resID)
474+
binary.Read(bytes.NewReader(b[dirStr+2:dirStr+2+length<<1]), le, resID)
475475
path += string(utf16.Decode(resID))
476476
} else { // ID entry
477-
path += strconv.Itoa(name)
477+
path += strconv.Itoa(int(name))
478478
}
479479

480-
if offsetToData < 0 { // Ptr to other directory if high bit is set
480+
if offsetToData&0x80000000 > 0 { // Ptr to other directory if high bit is set
481481
// Recursively get the res from the sub dirs
482-
l := parseDir(b, offsetToData & 0x7FFFFFFF, path+"/", addr)
482+
l := parseDir(b, int(offsetToData&0x7FFFFFFF), path+"/", addr)
483483
res = append(res, l...)
484484
continue
485485
}

0 commit comments

Comments
 (0)