mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
Fix s3select TRIM function's nil pointer dereference bug (#7817)
This commit is contained in:
parent
48cb271a46
commit
23b9df0694
@ -274,6 +274,15 @@ func (e *FuncExpr) analyze(s *Select) (result qProp) {
|
||||
}
|
||||
return result
|
||||
|
||||
case sqlFnTrim:
|
||||
if e.Trim.TrimChars != nil {
|
||||
result.combine(e.Trim.TrimChars.analyze(s))
|
||||
}
|
||||
if e.Trim.TrimFrom != nil {
|
||||
result.combine(e.Trim.TrimFrom.analyze(s))
|
||||
}
|
||||
return result
|
||||
|
||||
case sqlFnSubstring:
|
||||
errVal := fmt.Errorf("Invalid argument(s) to %s", string(funcName))
|
||||
result.combine(e.Substring.Expr.analyze(s))
|
||||
|
@ -337,20 +337,25 @@ func handleSQLSubstring(r Record, e *SubstringFunc) (val *Value, err error) {
|
||||
}
|
||||
|
||||
func handleSQLTrim(r Record, e *TrimFunc) (res *Value, err error) {
|
||||
charsV, cerr := e.TrimChars.evalNode(r)
|
||||
if cerr != nil {
|
||||
return nil, cerr
|
||||
}
|
||||
inferTypeAsString(charsV)
|
||||
chars, ok := charsV.ToString()
|
||||
if !ok {
|
||||
return nil, errNonStringTrimArg
|
||||
chars := ""
|
||||
ok := false
|
||||
if e.TrimChars != nil {
|
||||
charsV, cerr := e.TrimChars.evalNode(r)
|
||||
if cerr != nil {
|
||||
return nil, cerr
|
||||
}
|
||||
inferTypeAsString(charsV)
|
||||
chars, ok = charsV.ToString()
|
||||
if !ok {
|
||||
return nil, errNonStringTrimArg
|
||||
}
|
||||
}
|
||||
|
||||
fromV, ferr := e.TrimFrom.evalNode(r)
|
||||
if ferr != nil {
|
||||
return nil, ferr
|
||||
}
|
||||
inferTypeAsString(fromV)
|
||||
from, ok := fromV.ToString()
|
||||
if !ok {
|
||||
return nil, errNonStringTrimArg
|
||||
|
Loading…
Reference in New Issue
Block a user