Skip to content

Commit

Permalink
Merge pull request #1612 from 4el0ve4ek/fix-panic-bind-toValue
Browse files Browse the repository at this point in the history
fix panic when error returned in bind/params.toValue
  • Loading branch information
asmyasnikov authored Jan 31, 2025
2 parents 2dc4784 + c3da7bc commit c26bf6e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Fixed panic when error returned from parsing sql params
* Fixed explicit null dereferenced issue in internal/credentials/static.go (CWE-476)

## v3.99.1
Expand Down
4 changes: 2 additions & 2 deletions internal/bind/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ func toValue(v interface{}) (_ value.Value, err error) {
vv, err := toValue(v.Field(i).Interface())
if err != nil {
return nil, xerrors.WithStackTrace(
fmt.Errorf("cannot parse %v as values of dict: %w",
v.Index(i).Interface(), err,
fmt.Errorf("cannot parse %v as values of struct: %w",
v.Field(i).Interface(), err,
),
)
}
Expand Down
10 changes: 10 additions & 0 deletions internal/bind/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,16 @@ func TestToValue(t *testing.T) {
)),
err: nil,
},
{
name: xtest.CurrentFileLine(),
src: struct {
A struct {
Unsupported string
} `sql:"A"`
}{},
dst: nil,
err: errUnsupportedType,
},
{
name: xtest.CurrentFileLine(),
src: []uint64{123, 123, 123, 123, 123, 123},
Expand Down

0 comments on commit c26bf6e

Please sign in to comment.