mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-28 07:24:06 +00:00
Add an assertion check to detect a null pointer case
Also preemptively block subsequent dereferences. Hopefully somebody will eventually hit an assertion failure here and report back to help me understand how such a situation could possibly arise, so I can decide whether to remove the assert and leave the new loop conditional intact or change it to match the intended behavior (e.g. it's possible `!active || active->empty()` would be preferable in some scenario). Spotted by Coverity.
This commit is contained in:
parent
196b5183b1
commit
151aa77d2c
@ -138,7 +138,12 @@ bool persist_file_context::clear_var(const std::string &global, bool immediate)
|
||||
ret = exists;
|
||||
}
|
||||
}
|
||||
while ((active->empty()) && (!namespace_.lineage_.empty())) {
|
||||
|
||||
// TODO: figure out when this is the case and adjust the next loop
|
||||
// condition accordingly. -- shadowm
|
||||
assert(active);
|
||||
|
||||
while (active && active->empty() && !namespace_.lineage_.empty()) {
|
||||
name_space prev = namespace_.prev();
|
||||
active = get_node(cfg_, prev);
|
||||
if (active == NULL) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user