Skip to content

Commit 4669b24

Browse files
committed
Allocate memory for 'PyBytesObject.ob_sval' if empty.
1 parent 9c9921c commit 4669b24

File tree

1 file changed

+2
-2
lines changed
  • graalpython/com.oracle.graal.python.cext/src

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ const char* PyTruffle_StringToCstr(void* o, int32_t strLen) {
265265

266266
const char* PyTruffle_ByteArrayToNative(const void* jbyteArray, int len) {
267267
int i;
268+
int size = len != 0 ? len : 1;
268269
char* barr = (const char*) malloc(len * sizeof(char));
269-
270+
barr[0] = '\0';
270271
for(i=0; i < len; i++) {
271272
barr[i] = (char) polyglot_get_array_element(jbyteArray, i);
272273
}
273-
274274
return (const char*) barr;
275275
}
276276

0 commit comments

Comments
 (0)