platform: check calloc result
This commit is contained in:
parent
81890b1fe9
commit
a1f0d28913
|
@ -136,7 +136,13 @@ int platform_adiv5_swdp_scan(uint32_t targetid)
|
|||
case BMP_TYPE_STLINKV2:
|
||||
{
|
||||
target_list_free();
|
||||
ADIv5_DP_t *dp = (void*)calloc(1, sizeof(*dp));
|
||||
|
||||
ADIv5_DP_t *dp = calloc(1, sizeof(*dp));
|
||||
if (!dp) { /* calloc failed: heap exhaustion */
|
||||
DEBUG_WARN("calloc: failed in %s\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (stlink_enter_debug_swd(&info, dp)) {
|
||||
free(dp);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue