Skip to content

Commit fc9fa7e

Browse files
committed
riscv_debug: Report malloc failure in target_description
1 parent 428bac6 commit fc9fa7e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/target/riscv_debug.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,9 @@ static const char *riscv_target_description(target_s *const target)
12821282
const size_t description_length =
12831283
riscv_build_target_description(NULL, 0, hart->address_width, hart->extensions) + 1U;
12841284
char *const description = malloc(description_length);
1285-
if (description)
1286-
(void)riscv_build_target_description(description, description_length, hart->address_width, hart->extensions);
1285+
if (!description) /* malloc failed: heap exhaustion */
1286+
DEBUG_ERROR("malloc: failed in %s\n", __func__);
1287+
else
1288+
riscv_build_target_description(description, description_length, hart->address_width, hart->extensions);
12871289
return description;
12881290
}

0 commit comments

Comments
 (0)