Skip to content

Commit

Permalink
fix: deep copy nil string (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantxie authored Nov 13, 2024
1 parent f66a3a7 commit 9685fc2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tool/internal_pkg/pluginmode/thriftgo/struct_tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,16 +713,17 @@ const FieldDeepCopyBaseType = `
{{- if .IsPointer}}
if {{$Src}} != nil {
{{- if IsGoStringType .TypeName}}
var tmp string
if *{{$Src}} != "" {
tmp := kutils.StringDeepCopy(*{{$Src}})
{{.Target}} = &tmp
tmp = kutils.StringDeepCopy(*{{$Src}})
}
{{.Target}} = &tmp
{{- else if .Type.Category.IsBinary}}
tmp := make([]byte, len(*{{$Src}}))
if len(*{{$Src}}) != 0 {
tmp := make([]byte, len(*{{$Src}}))
copy(tmp, *{{$Src}})
{{.Target}} = &tmp
}
{{.Target}} = &tmp
{{- else}}
tmp := *{{$Src}}
{{.Target}} = &tmp
Expand Down

0 comments on commit 9685fc2

Please sign in to comment.