File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -280,12 +280,17 @@ static void riscv_deinit_target(struct target *target)
280280 free (info );
281281 }
282282 /* Free the shared structure use for most registers. */
283- free (target -> reg_cache -> reg_list [0 ].arch_info );
284- /* Free the ones we allocated separately. */
285- for (unsigned i = GDB_REGNO_COUNT ; i < target -> reg_cache -> num_regs ; i ++ )
286- free (target -> reg_cache -> reg_list [i ].arch_info );
287- free (target -> reg_cache -> reg_list );
288- free (target -> reg_cache );
283+ if (target -> reg_cache ) {
284+ if (target -> reg_cache -> reg_list ) {
285+ if (target -> reg_cache -> reg_list [0 ].arch_info )
286+ free (target -> reg_cache -> reg_list [0 ].arch_info );
287+ /* Free the ones we allocated separately. */
288+ for (unsigned i = GDB_REGNO_COUNT ; i < target -> reg_cache -> num_regs ; i ++ )
289+ free (target -> reg_cache -> reg_list [i ].arch_info );
290+ free (target -> reg_cache -> reg_list );
291+ }
292+ free (target -> reg_cache );
293+ }
289294 target -> arch_info = NULL ;
290295}
291296
You can’t perform that action at this time.
0 commit comments