Skip to content

Commit f5c1ee0

Browse files
GwendalRaoulSkypLabs
authored andcommitted
Arg format: use right format for s#
s# requires Py_ssize_t for the length. Using an unsigned int results in a corrupted stack on 64bits arch. It was mentioned in #55
1 parent 43cc6d6 commit f5c1ee0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/python4yahdlc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ static PyObject *get_data(PyObject *self, PyObject *args)
2020
int ret;
2121
const char *frame_data;
2222
char recv_data[TOTAL_FRAME_LENGTH];
23-
unsigned int buf_length = 0, recv_length = 0;
23+
Py_ssize_t buf_length = 0;
24+
unsigned int recv_length = 0;
2425
yahdlc_control_t control;
2526

2627
if (!PyArg_ParseTuple(args, "s#", &frame_data, &buf_length))
@@ -89,7 +90,8 @@ static PyObject *frame_data(PyObject *self, PyObject *args)
8990
int ret;
9091
const char *send_data;
9192
char frame_data[TOTAL_FRAME_LENGTH];
92-
unsigned int data_length = 0, frame_length = 0, frame_type = YAHDLC_FRAME_DATA, seq_no = 0;
93+
Py_ssize_t data_length = 0;
94+
unsigned int frame_length = 0, frame_type = YAHDLC_FRAME_DATA, seq_no = 0;
9395
yahdlc_control_t control;
9496

9597
if (!PyArg_ParseTuple(args, "s#|II", &send_data, &data_length, &frame_type, &seq_no))

0 commit comments

Comments
 (0)