Skip to content

Panic when submitting non-existing files to Load() #33

@alessio

Description

@alessio

Hi,

I'm submitting a slice of three files to ini.Load():

cfg, err := ini.Load("/etc/securepass.conf", "/usr/local/etc/securepass.conf", "securepass.conf")

Only the latter exists and has the correct permissions set. Likewise the Python ConfigParser module, it would be great if the function could read the configuration from only those accessible or return an empty configuration if no existing files were provided.

$ ~/go/src/github.com/garlsecurity/go-securepass$ go run spctl/main.go 
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4811b2]

goroutine 1 [running]:
gopkg.in/ini%2ev1.(*File).GetSection(0x0, 0x7fa130, 0x7, 0x0, 0x0, 0x0)
    /home/SMARTODDS/tregliaa/go/src/gopkg.in/ini.v1/ini.go:976 +0x72
main.loadConfiguration()
    /home/SMARTODDS/tregliaa/go/src/github.com/garlsecurity/go-securepass/spctl/main.go:50 +0xc2
main.main()
    /home/SMARTODDS/tregliaa/go/src/github.com/garlsecurity/go-securepass/spctl/main.go:60 +0x1c

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1721 +0x1
exit status 2

Thanks for considering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions