Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call checkForUpdates without a fetcher #26

Merged
merged 1 commit into from
Sep 19, 2019

Conversation

camh-
Copy link
Collaborator

@camh- camh- commented Sep 19, 2019

ProxyFinder.checkForUpdates() should only be called if pf.fetcher is
not nil. It does this on the HTTP serving path, but not on the initial
call. Move the call to checkForUpdates() inside the branch that
creates the pacfetcher.

Fixes this bug:

sam@sam-desktop:~/alpaca$ go build && ./alpaca
2019/09/19 19:13:28 proxyfinder.go:24: No PAC URL specified or detected; all requests will be made directly
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x855e7e]

goroutine 1 [running]:
main.(*pacFetcher).download(0x0, 0x0, 0x0, 0x0)
        /home/sam/alpaca/pacfetcher.go:51 +0x4e
main.(*ProxyFinder).checkForUpdates(0xc00000e0c0)
        /home/sam/alpaca/proxyfinder.go:50 +0x76
main.NewProxyFinder(0x0, 0x0, 0xc000170480, 0x0)
        /home/sam/alpaca/proxyfinder.go:31 +0xa9
main.main()
        /home/sam/alpaca/main.go:67 +0x2b8

`ProxyFinder.checkForUpdates()` should only be called if `pf.fetcher` is
not nil. It does this on the HTTP serving path, but not on the initial
call. Move the call to `checkForUpdates()` inside the branch that
creates the pacfetcher.

Fixes this bug:

    sam@sam-desktop:~/alpaca$ go build && ./alpaca
    2019/09/19 19:13:28 proxyfinder.go:24: No PAC URL specified or detected; all requests will be made directly
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x855e7e]

    goroutine 1 [running]:
    main.(*pacFetcher).download(0x0, 0x0, 0x0, 0x0)
            /home/sam/alpaca/pacfetcher.go:51 +0x4e
    main.(*ProxyFinder).checkForUpdates(0xc00000e0c0)
            /home/sam/alpaca/proxyfinder.go:50 +0x76
    main.NewProxyFinder(0x0, 0x0, 0xc000170480, 0x0)
            /home/sam/alpaca/proxyfinder.go:31 +0xa9
    main.main()
            /home/sam/alpaca/main.go:67 +0x2b8
Copy link
Owner

@samuong samuong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@camh- camh- merged commit 029ebc6 into samuong:master Sep 19, 2019
@camh- camh- deleted the fix-check-for-updates branch September 19, 2019 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants