Skip to content

Commit c26bf6e

Browse files
authored
Merge pull request #1612 from 4el0ve4ek/fix-panic-bind-toValue
fix panic when error returned in bind/params.toValue
2 parents 2dc4784 + c3da7bc commit c26bf6e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* Fixed panic when error returned from parsing sql params
12
* Fixed explicit null dereferenced issue in internal/credentials/static.go (CWE-476)
23

34
## v3.99.1

internal/bind/params.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ func toValue(v interface{}) (_ value.Value, err error) {
315315
vv, err := toValue(v.Field(i).Interface())
316316
if err != nil {
317317
return nil, xerrors.WithStackTrace(
318-
fmt.Errorf("cannot parse %v as values of dict: %w",
319-
v.Index(i).Interface(), err,
318+
fmt.Errorf("cannot parse %v as values of struct: %w",
319+
v.Field(i).Interface(), err,
320320
),
321321
)
322322
}

internal/bind/params_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,16 @@ func TestToValue(t *testing.T) {
425425
)),
426426
err: nil,
427427
},
428+
{
429+
name: xtest.CurrentFileLine(),
430+
src: struct {
431+
A struct {
432+
Unsupported string
433+
} `sql:"A"`
434+
}{},
435+
dst: nil,
436+
err: errUnsupportedType,
437+
},
428438
{
429439
name: xtest.CurrentFileLine(),
430440
src: []uint64{123, 123, 123, 123, 123, 123},

0 commit comments

Comments
 (0)