mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-12 10:40:12 +00:00
Bug 1021335: Fix DataChannel leak of recv buffers from SCTP r=tuexen
This commit is contained in:
parent
539d95f87e
commit
63f0d0928d
@ -1318,6 +1318,7 @@ DataChannelConnection::HandleDataMessage(uint32_t ppid,
|
||||
// Since this is rare and non-performance, keep a single list of queued
|
||||
// data messages to deliver once the channel opens.
|
||||
LOG(("Queuing data for stream %u, length %u", stream, length));
|
||||
// Copies data
|
||||
mQueuedData.AppendElement(new QueuedDataMessage(stream, ppid, data, length));
|
||||
return;
|
||||
}
|
||||
@ -1326,7 +1327,7 @@ DataChannelConnection::HandleDataMessage(uint32_t ppid,
|
||||
NS_ENSURE_TRUE_VOID(channel->mState != CLOSED);
|
||||
|
||||
{
|
||||
nsAutoCString recvData(buffer, length);
|
||||
nsAutoCString recvData(buffer, length); // copies (<64) or allocates
|
||||
bool is_binary = true;
|
||||
|
||||
if (ppid == DATA_CHANNEL_PPID_DOMSTRING ||
|
||||
@ -1933,6 +1934,11 @@ DataChannelConnection::ReceiveCallback(struct socket* sock, void *data, size_t d
|
||||
HandleMessage(data, datalen, ntohl(rcv.rcv_ppid), rcv.rcv_sid);
|
||||
}
|
||||
}
|
||||
// sctp allocates 'data' with malloc(), and expects the receiver to free
|
||||
// it (presumably with free).
|
||||
// XXX future optimization: try to deliver messages without an internal
|
||||
// alloc/copy, and if so delay the free until later.
|
||||
free(data);
|
||||
// usrsctp defines the callback as returning an int, but doesn't use it
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user