@@ -53,7 +53,7 @@ static void callback_friend_request(Tox *tox, const uint8_t *public_key,
5353 bytes_to_hex_string (public_key , TOX_PUBLIC_KEY_SIZE , buf );
5454
5555 PyObject_CallMethod ((PyObject * )self , "on_friend_request" , "ss#" , buf , data ,
56- length - (data [length - 1 ] == 0 ));
56+ length - (length > 0 && data [length - 1 ] == 0 ));
5757}
5858
5959static void callback_friend_message (Tox * tox , uint32_t friendnumber ,
@@ -62,22 +62,23 @@ static void callback_friend_message(Tox *tox, uint32_t friendnumber,
6262 void * self ) {
6363 PyObject_CallMethod ((PyObject * )self , "on_friend_message" , "iis#" ,
6464 friendnumber , type , message ,
65- length - (message [length - 1 ] == 0 ));
65+ length - (length > 0 && message [length - 1 ] == 0 ));
6666}
6767
6868static void callback_friend_name (Tox * tox , uint32_t friendnumber ,
6969 const uint8_t * newname , size_t length ,
7070 void * self ) {
7171 PyObject_CallMethod ((PyObject * )self , "on_friend_name" , "is#" , friendnumber ,
72- newname , length - (newname [length - 1 ] == 0 ));
72+ newname ,
73+ length - (length > 0 && newname [length - 1 ] == 0 ));
7374}
7475
7576static void callback_friend_status_message (Tox * tox , uint32_t friendnumber ,
7677 const uint8_t * newstatus ,
7778 size_t length , void * self ) {
7879 PyObject_CallMethod ((PyObject * )self , "on_friend_status_message" , "is#" ,
7980 friendnumber , newstatus ,
80- length - (newstatus [length - 1 ] == 0 ));
81+ length - (length > 0 && newstatus [length - 1 ] == 0 ));
8182}
8283
8384static void callback_friend_status (Tox * tox , uint32_t friendnumber ,
@@ -120,7 +121,7 @@ static void callback_conference_message(Tox *tox, uint32_t conference_number,
120121 void * self ) {
121122 PyObject_CallMethod ((PyObject * )self , "on_conference_message" , "iiis#" ,
122123 conference_number , peer_number , type , message ,
123- length - (message [length - 1 ] == 0 ));
124+ length - (length > 0 && message [length - 1 ] == 0 ));
124125}
125126
126127static void callback_conference_peer_name (Tox * tox , uint32_t conference_number ,
0 commit comments