Skip to content

Commit

Permalink
Preparing for release 1.0.2
Browse files Browse the repository at this point in the history
* Fixed populate panic for a nil pointer

* Update date
  • Loading branch information
Alex authored Aug 17, 2017
1 parent c79dcee commit cf30b1c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Changelog

## v1.1.0 (not released yet)
## v1.0.2 (2017-08-17)

- No changes yet.
- Fixed populate panic for a nil pointer.

## v1.0.1 (2017-08-04)

Expand Down
12 changes: 12 additions & 0 deletions static_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,15 @@ func TestTextUnmarshalerOnMissingValue(t *testing.T) {
ds := duckTales{}
require.NoError(t, p.Get(Root).Populate(&ds))
}

func TestPopulateNilPointer(t *testing.T) {
t.Parallel()

p, err := NewStaticProvider(13)
require.NoError(t, err)

var i *int
err = p.Get(Root).Populate(i)
require.Error(t, err)
assert.Contains(t, err.Error(), `can't populate nil *int`)
}
7 changes: 6 additions & 1 deletion value.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ func (cv Value) Populate(target interface{}) error {
return fmt.Errorf("can't populate non pointer type %T", target)
}

ptr := reflect.Indirect(reflect.ValueOf(target))
if !ptr.IsValid() {
return fmt.Errorf("can't populate nil %T", target)
}

d := decoder{Value: &cv, m: make(map[interface{}]struct{})}

return d.unmarshal(cv.key, reflect.Indirect(reflect.ValueOf(target)), "")
return d.unmarshal(cv.key, ptr, "")
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
package config // import "go.uber.org/config"

// Version is the current version of config.
const Version = "1.1.0"
const Version = "1.0.2"

0 comments on commit cf30b1c

Please sign in to comment.