Bug 1082524 - Do not deref null pointers in link_map. r=nfroyd

This commit is contained in:
Mike Hommey 2014-10-18 09:27:55 +09:00
parent 329a5d00db
commit a6593e4218

View File

@ -885,16 +885,18 @@ ElfLoader::DebuggerHelper::Remove(ElfLoader::link_map *map)
dbg->r_brk();
if (dbg->r_map == map)
dbg->r_map = map->l_next;
else
else if (map->l_prev) {
map->l_prev->l_next = map->l_next;
}
if (map == firstAdded) {
firstAdded = map->l_prev;
/* When removing the first added library, its l_next is going to be
* data handled by the system linker, and that data may be read-only */
EnsureWritable w(&map->l_next->l_prev);
map->l_next->l_prev = map->l_prev;
} else
} else if (map->l_next) {
map->l_next->l_prev = map->l_prev;
}
dbg->r_state = r_debug::RT_CONSISTENT;
dbg->r_brk();
}