File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
graalpython/com.oracle.graal.python.cext/src Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -58,10 +58,14 @@ Py_ssize_t PyBytes_Size(PyObject *bytes) {
58
58
UPCALL_ID (PyBytes_FromStringAndSize );
59
59
UPCALL_ID (PyTruffle_Bytes_EmptyWithCapacity );
60
60
PyObject * PyBytes_FromStringAndSize (const char * str , Py_ssize_t sz ) {
61
- if (str != NULL ) {
62
- return ((fromStringAndSize_fun_t )_jls_PyBytes_FromStringAndSize )(polyglot_from_i8_array (str , sz ), sz );
63
- }
64
- return UPCALL_CEXT_O (_jls_PyTruffle_Bytes_EmptyWithCapacity , sz );
61
+ if (sz < 0 ) {
62
+ PyErr_SetString (PyExc_SystemError , "Negative size passed to PyBytes_FromStringAndSize" );
63
+ return NULL ;
64
+ }
65
+ if (str != NULL ) {
66
+ return ((fromStringAndSize_fun_t )_jls_PyBytes_FromStringAndSize )(polyglot_from_i8_array (str , sz ), sz );
67
+ }
68
+ return UPCALL_CEXT_O (_jls_PyTruffle_Bytes_EmptyWithCapacity , sz );
65
69
}
66
70
67
71
PyObject * PyBytes_FromString (const char * str ) {
You can’t perform that action at this time.
0 commit comments