Site.PathSpec access causes panic

Hello,
I would like my themes to read themes/mytheme/theme.toml. So I created the following function inside hugolib/site.go:

func themeConfig(s *Site) (*viper.Viper, error) {
	s.Log.INFO.Print("s.PathSpec: %v", s.PathSpec.Theme())

	if s.PathSpec.ThemeSet() {
		osFs := hugofs.Os
		source := s.PathSpec.GetRelativeThemeDir()

		return LoadConfig(osFs, source, "theme")
	}
	return nil, nil
}

I also added the following field inside the Site{} struct:

type Site struct {
  // [...]
  themeCfg *viper.Viper
}

Then in hugolib/site.go#241, I added the following line to read config:

s.themeCfg = themeConfig(s)

This always end with a panic:

$ ./hugo -s ~/dev/hugo-inheritance-example/
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x546d53]

goroutine 1 [running]:
panic(0xabfce0, 0xc420012120)
/usr/lib/go-1.7/src/runtime/panic.go:500 +0x1a1
github.com/spf13/hugo/hugolib.themeConfig(0xc420200500, 0x0)
/home/adrien/dev/go/src/github.com/spf13/hugo/hugolib/site.go:2179 +0x53
github.com/spf13/hugo/hugolib.newSite(0xc4202340e0, 0xc420019000, 0xc420021620, 0xecf1a0, 0xc4201fb680, 0x0, 0x0, 0x0, 0x0, 0x0, …)
/home/adrien/dev/go/src/github.com/spf13/hugo/hugolib/site.go:215 +0xbcd
github.com/spf13/hugo/hugolib.createSitesFromConfig(0xc4202340e0, 0xc420019000, 0xc420021620, 0xecf1a0, 0xc4201fb680, 0x0, 0x0, 0x0, 0x0, 0x0, …)
/home/adrien/dev/go/src/github.com/spf13/hugo/hugolib/hugo_sites.go:177 +0x415
github.com/spf13/hugo/hugolib.NewHugoSites(0xc4202340e0, 0xc420019000, 0x0, 0xecf1a0, 0xc4201fb680, 0x0, 0x0, 0x0, 0x0, 0x0, …)
/home/adrien/dev/go/src/github.com/spf13/hugo/hugolib/hugo_sites.go:127 +0x52
github.com/spf13/hugo/commands.(*commandeer).initSites(0xc420014940, 0x0, 0xc4200191c0)
/home/adrien/dev/go/src/github.com/spf13/hugo/commands/hugo.go:735 +0x56
github.com/spf13/hugo/commands.(*commandeer).buildSites(0xc420014940, 0x0, 0x0, 0x18)
/home/adrien/dev/go/src/github.com/spf13/hugo/commands/hugo.go:746 +0x3a
github.com/spf13/hugo/commands.(*commandeer).build(0xc420014940, 0x0, 0x0, 0x0, 0x0, 0x0)
/home/adrien/dev/go/src/github.com/spf13/hugo/commands/hugo.go:529 +0x223
github.com/spf13/hugo/commands.glob..func8(0xf0c980, 0xc4201b24a0, 0x0, 0x2, 0x0, 0x0)
/home/adrien/dev/go/src/github.com/spf13/hugo/commands/hugo.go:133 +0x145
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).execute(0xf0c980, 0xc42000c220, 0x2, 0x2, 0xf0c980, 0xc42000c220)
/home/adrien/dev/go/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:620 +0x247
github.com/spf13/hugo/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xf0c980, 0xbee810, 0xf160d0, 0xc400000001)
/home/adrien/dev/go/src/github.com/spf13/hugo/vendor/github.com/spf13/cobra/command.go:699 +0x367
github.com/spf13/hugo/commands.Execute()
/home/adrien/dev/go/src/github.com/spf13/hugo/commands/hugo.go:172 +0x6d
main.main()
/home/adrien/dev/go/src/github.com/spf13/hugo/main.go:27 +0x36

I think that at this stage s.PathSpec is not defined, but I cannot figure out why. Thanks by advance for any help!