Added check code to prevent the protocol crashing in certain situations.

This commit is contained in:
barrett 2012-03-08 01:38:55 +00:00
parent 0237a48a53
commit fd546ea9ae

View File

@ -194,7 +194,8 @@ MSNP::MSNP()
looper->Run(); looper->Run();
fAvatarRunner = new BMessageRunner(*mess, new BMessage(kAvatarCheckMessage), fRunnerTime); fAvatarRunner = new BMessageRunner(*mess, new BMessage(kAvatarCheckMessage), fRunnerTime);
if (fAvatarRunner->InitCheck() != B_OK) { if (fAvatarRunner->InitCheck() != B_OK) {
printf("Avatar MessageRunner error %s\n", fAvatarRunner->InitCheck()); printf("Avatar MessageRunner error %s\n",
strerror(fAvatarRunner->InitCheck()));
} }
} }
@ -408,8 +409,10 @@ MSNP::Process(BMessage* msg)
fMainConnection->requestSwitchboardConnection(container); fMainConnection->requestSwitchboardConnection(container);
} else { } else {
MSN::SwitchboardServerConnection* conn = fSwitchboardList.ItemAt(y)->second; MSN::SwitchboardServerConnection* conn = fSwitchboardList.ItemAt(y)->second;
conn->sendTypingNotification(); if (conn != NULL && conn->isConnected()) {
conn->sendMessage(string(sms)); conn->sendTypingNotification();
conn->sendMessage(string(sms));
}
BMessage msg(IM_MESSAGE); BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_SENT); msg.AddInt32("im_what", IM_MESSAGE_SENT);
@ -440,7 +443,8 @@ MSNP::Process(BMessage* msg)
if (count != 0) { if (count != 0) {
for (x=0; x < count; x++) { for (x=0; x < count; x++) {
if (fSwitchboardList.ItemAt(x)->first == id) { if (fSwitchboardList.ItemAt(x)->first == id) {
fSwitchboardList.ItemAt(x)->second->sendTypingNotification(); if (fSwitchboardList.ItemAt(x)->second != NULL)
fSwitchboardList.ItemAt(x)->second->sendTypingNotification();
break; break;
} }
} }