Skip to content

Commit

Permalink
fix: empty property in msg (#291)
Browse files Browse the repository at this point in the history
Co-authored-by: Hu Yueh-Wei <[email protected]>
  • Loading branch information
leoadonia and halajohn authored Nov 18, 2024
1 parent aae1e59 commit 0e8de3d
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 312 deletions.
10 changes: 10 additions & 0 deletions core/src/ten_runtime/binding/go/interface/ten/msg_property.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ func (p *msg) getPropertyString(path string) (string, error) {
)
}

if pSize == 0 {
// We can not allocate a []byte with size 0, so just return "".
return "", nil
}

return getPropStr(
uintptr(pSize),
func(v unsafe.Pointer) C.ten_go_status_t {
Expand Down Expand Up @@ -116,6 +121,11 @@ func (p *msg) getPropertyBytes(path string) ([]byte, error) {
)
}

if pSize == 0 {
// We can not allocate a []byte with size 0, so just return nil.
return nil, nil
}

return getPropBytes(
uintptr(pSize),
func(v unsafe.Pointer) C.ten_go_status_t {
Expand Down
Loading

0 comments on commit 0e8de3d

Please sign in to comment.