Skip to content

Commit 6379eb7

Browse files
committed
Fix: hide null character for interop
1 parent 67a3438 commit 6379eb7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

graalpython/com.oracle.graal.python.cext/src/unicodeobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,8 @@ PyObject* PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar) {
514514

515515
/* add one to size for the null character */
516516
int8_t* ptr = (int8_t*) calloc(size + 1, kind);
517-
return _jls_PyUnicode_New(polyglot_from_i8_array((int8_t*)ptr, (size + 1) * kind), kind, is_ascii);
517+
/* We intentionally reduce the size by one because interop users should not see the null character. */
518+
return _jls_PyUnicode_New(polyglot_from_i8_array((int8_t*)ptr, size * kind), kind, is_ascii);
518519
}
519520

520521
UPCALL_ID(PyUnicode_Compare);

0 commit comments

Comments
 (0)