Skip to content

Commit

Permalink
Avoid dereferencing msg.ps_msg if it is NULL. Properly protect agains…
Browse files Browse the repository at this point in the history
…t a removed current entry in map iterator.
  • Loading branch information
FedeDP committed Jul 17, 2019
1 parent ff976c9 commit 335770c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions Lib/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,19 @@ map_ret_code map_itr_remove(map_itr_t *itr) {
const char *map_itr_get_key(const map_itr_t *itr) {
MOD_RET_ASSERT(itr, NULL);

return itr->curr->key;
if (!itr->removed) {
return itr->curr->key;
}
return NULL;
}

void *map_itr_get_data(const map_itr_t *itr) {
MOD_RET_ASSERT(itr, NULL);

return itr->curr->data;
if (!itr->removed) {
return itr->curr->data;
}
return NULL;
}

map_ret_code map_itr_set_data(const map_itr_t *itr, void *value) {
Expand Down
2 changes: 1 addition & 1 deletion Lib/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static int recv_events(m_context *c, int timeout) {

if (!msg.is_pubsub || (msg.ps_msg && msg.ps_msg->type != POISON_PILL)) {
run_pubsub_cb(mod, &msg);
} else if (msg.ps_msg->type == POISON_PILL) {
} else if (msg.ps_msg) {
MODULE_DEBUG("PoisonPilling '%s'.\n", mod->name);
stop(mod, true);
}
Expand Down

0 comments on commit 335770c

Please sign in to comment.