mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Realloc apparently doesn't always behave like free() if size is zero.
This commit is contained in:
parent
88986f793a
commit
17890b1f61
|
@ -704,6 +704,12 @@ int DHT_delfriend(uint8_t *client_id)
|
|||
CLIENT_ID_SIZE );
|
||||
}
|
||||
|
||||
if (num_friends == 0) {
|
||||
free(friends_list);
|
||||
friends_list = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
temp = realloc(friends_list, sizeof(Friend) * (num_friends));
|
||||
|
||||
if (temp == NULL)
|
||||
|
|
|
@ -319,6 +319,12 @@ static void free_connections(void)
|
|||
if (connections_length == i)
|
||||
return;
|
||||
|
||||
if (i == 0) {
|
||||
free(connections);
|
||||
connections = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
Connection *temp;
|
||||
temp = realloc(connections, sizeof(Connection) * i);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user