Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Commit 0ae9380

Browse files
Christopher Schmitthush-hush
Christopher Schmitt
authored andcommitted
Use GoStringN inside _AsString functions for bytes as they may contain NULLs
1 parent 0b25cc5 commit 0ae9380

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

byte_array.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func PyByteArray_Size(o *PyObject) int {
5252

5353
//PyByteArray_AsString : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_AsString
5454
func PyByteArray_AsString(o *PyObject) string {
55-
return C.GoString(C.PyByteArray_AsString(toc(o)))
55+
return C.GoStringN(C.PyByteArray_AsString(toc(o)), C.int(C.PyByteArray_Size(toc(o))))
5656
}
5757

5858
//PyByteArray_Resize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Resize

bytes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func PyBytes_Size(o *PyObject) int {
4747

4848
//PyBytes_AsString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_AsString
4949
func PyBytes_AsString(o *PyObject) string {
50-
return C.GoString(C.PyBytes_AsString(toc(o)))
50+
return C.GoStringN(C.PyBytes_AsString(toc(o)), C.int(C.PyBytes_Size(toc(o))))
5151
}
5252

5353
//PyBytes_Concat : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Concat

0 commit comments

Comments
 (0)