Skip to content

Commit 1b573c2

Browse files
committed
Fix possible panic on short slices
1 parent cf3f8f0 commit 1b573c2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/mime/type_unix.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ func loadMimeGlobsFile(filename string) error {
4343
for scanner.Scan() {
4444
// Each line should be of format: weight:mimetype:*.ext
4545
fields := strings.Split(scanner.Text(), ":")
46-
if len(fields) < 2 || fields[0][0] == '#' || fields[2][0] != '*' {
46+
if len(fields) < 3 || len(fields[0]) < 1 || len(fields[2]) < 2 {
47+
continue
48+
} else if fields[0][0] == '#' || fields[2][0] != '*' {
4749
continue
4850
}
4951

0 commit comments

Comments
 (0)