Don't panic when using nil pointer, close #4168

This commit is contained in:
Jinzhu 2021-03-10 19:32:56 +08:00
parent 675de6fc16
commit 14b9bd163c
1 changed files with 1 additions and 1 deletions

View File

@ -96,7 +96,7 @@ func (p *processor) Execute(db *DB) {
if stmt.Dest != nil {
stmt.ReflectValue = reflect.ValueOf(stmt.Dest)
for stmt.ReflectValue.Kind() == reflect.Ptr {
if stmt.ReflectValue.IsNil() {
if stmt.ReflectValue.IsNil() && stmt.ReflectValue.CanAddr() {
stmt.ReflectValue.Set(reflect.New(stmt.ReflectValue.Type().Elem()))
break
}