Skip to content

Commit 94cc77e

Browse files
committed
Fix random signal5 crash on some debugger heap tests
1 parent ddaada5 commit 94cc77e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

libr/core/dmh_glibc.inc.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,19 +199,23 @@ R_API double GH(get_glibc_version)(RCore *core, const char *libc_path) {
199199
}
200200

201201
static const char* GH(get_libc_filename_from_maps)(RCore *core) {
202-
R_RETURN_VAL_IF_FAIL (core && core->dbg && core->dbg->maps && core->bin && core->bin->file, NULL);
202+
R_RETURN_VAL_IF_FAIL (core && core->dbg && core->dbg->maps, NULL);
203203
RListIter *iter;
204204
RDebugMap *map = NULL;
205205

206206
r_debug_map_sync (core->dbg);
207207

208+
const char *binfile = (core->bin && core->bin->file)? core->bin->file: NULL;
208209
// Search for binary in memory maps named *libc-* or *libc.* *libc6_* or similiar
209210
// TODO: This is very brittle, other bin names or LD_PRELOAD could be a problem
210211
r_list_foreach (core->dbg->maps, iter, map) {
211-
if (!map->name || r_str_startswith (core->bin->file, map->name)) {
212+
if (!map->name) {
213+
continue;
214+
}
215+
if (binfile && r_str_startswith (binfile, map->name)) {
212216
continue;
213217
}
214-
if (r_regex_match (".*libc6?[-_\\.]", "e", r_file_basename(map->name))) {
218+
if (r_regex_match (".*libc6?[-_\\.]", "e", r_file_basename (map->name))) {
215219
r_config_set (core->config, "dbg.glibc.path", map->file);
216220
return map->file;
217221
}

0 commit comments

Comments
 (0)