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

View file

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