ricochet
ricochet copied to clipboard
src/core/IncomingRequestManager.cpp
Is the request object supposed to be deleted if BUG() is reached? The new request is assigned to a parent (this) object so it will be eventually removed.
IncomingContactRequest *request = requestFromHostname(hostname.toLatin1());
bool newRequest = false;
if (request) {
// Update the existing request
request->setChannel(channel);
request->renew();
} else {
newRequest = true;
request = new IncomingContactRequest(this, hostname.toLatin1());
request->setChannel(channel);
}
/* It shouldn't be possible to get an incoming contact request for a known
* contact, including an outgoing request. Those are implicitly accepted at
* a different level. */
if (contacts->lookupHostname(hostname)) {
if(newRequest)
request->deleteLater(); // Delete?
BUG() << "Created an inbound contact request matching a known contact; this shouldn't be allowed";
return;
}
qDebug() << "Recording" << (newRequest ? "new" : "existing") << "incoming contact request from" << hostname;
channel->setResponseStatus(Response::Pending);
request->save();
if (newRequest) {
m_requests.append(request);
emit requestAdded(request);
}