From 87a47e241ce55f01ddd66475ff36420e5f020030 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 4 Nov 2015 11:23:57 +0100 Subject: [PATCH] CID 22479 Dereference after null check CID 22478 Dereference after null check CID 22477 Dereference after null check CID 22476 Dereference after null check CID 22475 Dereference after null check --- src/bindings.c | 33 ++++++++++++++++++++++----------- storage | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index c2f18d8d5..20a8192e1 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -1,4 +1,4 @@ -/* +/* +-------------------+ | | Enno Rehling | Eressea PBEM host | Christian Schlittchen @@ -237,11 +237,15 @@ static int tolua_message_unit(lua_State * L) unit *sender = (unit *)tolua_tousertype(L, 1, 0); unit *target = (unit *)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); - deliverMail(target->faction, sender->region, sender, str, target); + } + else { + deliverMail(target->faction, sender->region, sender, str, target); + } return 0; } @@ -250,11 +254,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); - deliverMail(target, sender->region, sender, str, NULL); + } + else { + deliverMail(target, sender->region, sender, str, NULL); + } return 0; } @@ -262,10 +270,13 @@ static int tolua_message_region(lua_State * L) { unit *sender = (unit *)tolua_tousertype(L, 1, 0); const char *str = tolua_tostring(L, 2, 0); - if (!sender) + if (!sender) { tolua_error(L, TOLUA_CAST "sender is nil", NULL); - ADDMSG(&sender->region->msgs, msg_message("mail_result", "unit message", - sender, str)); + } + else { + ADDMSG(&sender->region->msgs, msg_message("mail_result", "unit message", + sender, str)); + } return 0; } @@ -1172,7 +1183,7 @@ int eressea_run(lua_State *L, const char *luafile) if (err != 0) { log_lua_error(L); } - else { + else { if (lua_isnumber(L, -1)) { err = (int)lua_tonumber(L, -1); } diff --git a/storage b/storage index 86b967441..1d92cb36d 160000 --- a/storage +++ b/storage @@ -1 +1 @@ -Subproject commit 86b96744157eb08c55998df4c12fa2e073005b49 +Subproject commit 1d92cb36df41c183c378aad17cbbfc0eddbb5c84