CID 22475 Dereference after null check

This commit is contained in:
Enno Rehling 2015-11-04 07:56:19 +01:00
parent 04b5bc0c60
commit 0be8724093
1 changed files with 9 additions and 5 deletions

View File

@ -250,11 +250,15 @@ static int tolua_message_faction(lua_State * L)
unit *sender = (unit *)tolua_tousertype(L, 1, 0);
faction *target = (faction *)tolua_tousertype(L, 2, 0);
const char *str = tolua_tostring(L, 3, 0);
if (!target)
if (!target) {
tolua_error(L, TOLUA_CAST "target is nil", NULL);
if (!sender)
}
else if (!sender) {
tolua_error(L, TOLUA_CAST "sender is nil", NULL);
}
else {
deliverMail(target, sender->region, sender, str, NULL);
}
return 0;
}