Skip to content

Commit

Permalink
Fix zipFiler crash on dirs with subdirs
Browse files Browse the repository at this point in the history
This happens since nodes for directories don't have
their "file" field initialized.

Signed-off-by: Tal Einat <[email protected]>
  • Loading branch information
taleinat committed May 2, 2020
1 parent 63bc934 commit 3032061
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion licensedb/filer/filer.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,13 @@ func (filer *zipFiler) ReadDir(path string) ([]File, error) {
}
result := make([]File, 0, len(node.children))
for name, child := range node.children {
isDir := true
if child.file != nil {
isDir = child.file.FileInfo().IsDir()
}
result = append(result, File{
Name: name,
IsDir: child.file.FileInfo().IsDir(),
IsDir: isDir,
})
}
return result, nil
Expand Down
Binary file added licensedb/filer/test_data/empty_sub_dir.zip
Binary file not shown.

0 comments on commit 3032061

Please sign in to comment.