mirror of
https://github.com/mappu/miqt.git
synced 2025-01-30 10:00:22 +00:00
genbindings: fix indexing of zero-length byte arrays
This commit is contained in:
parent
a80a93966d
commit
c80c0ff441
@ -333,7 +333,11 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble
|
|||||||
|
|
||||||
gfs.imports["unsafe"] = struct{}{}
|
gfs.imports["unsafe"] = struct{}{}
|
||||||
preamble += nameprefix + "_alias := C.struct_miqt_string{}\n"
|
preamble += nameprefix + "_alias := C.struct_miqt_string{}\n"
|
||||||
|
preamble += "if len(" + p.ParameterName + ") > 0 {\n"
|
||||||
preamble += nameprefix + "_alias.data = (*C.char)(unsafe.Pointer(&" + p.ParameterName + "[0]))\n"
|
preamble += nameprefix + "_alias.data = (*C.char)(unsafe.Pointer(&" + p.ParameterName + "[0]))\n"
|
||||||
|
preamble += "} else {\n"
|
||||||
|
preamble += nameprefix + "_alias.data = (*C.char)(unsafe.Pointer(nil))\n"
|
||||||
|
preamble += "}\n"
|
||||||
preamble += nameprefix + "_alias.len = C.size_t(len(" + p.ParameterName + "))\n"
|
preamble += nameprefix + "_alias.len = C.size_t(len(" + p.ParameterName + "))\n"
|
||||||
|
|
||||||
rvalue = nameprefix + "_alias"
|
rvalue = nameprefix + "_alias"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user