mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-30 06:50:57 +00:00
cris: do not leak struct cris_disasm_data
Use a stack-allocated struct to avoid a memory leak. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
0287d89f3e
commit
9739b11adc
59
disas/cris.c
59
disas/cris.c
@ -1294,24 +1294,17 @@ static int cris_constraint
|
|||||||
/* Parse disassembler options and store state in info. FIXME: For the
|
/* Parse disassembler options and store state in info. FIXME: For the
|
||||||
time being, we abuse static variables. */
|
time being, we abuse static variables. */
|
||||||
|
|
||||||
static bfd_boolean
|
static void
|
||||||
cris_parse_disassembler_options (disassemble_info *info,
|
cris_parse_disassembler_options (struct cris_disasm_data *disdata,
|
||||||
|
char *disassembler_options,
|
||||||
enum cris_disass_family distype)
|
enum cris_disass_family distype)
|
||||||
{
|
{
|
||||||
struct cris_disasm_data *disdata;
|
|
||||||
|
|
||||||
info->private_data = calloc (1, sizeof (struct cris_disasm_data));
|
|
||||||
disdata = (struct cris_disasm_data *) info->private_data;
|
|
||||||
if (disdata == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
/* Default true. */
|
/* Default true. */
|
||||||
disdata->trace_case
|
disdata->trace_case
|
||||||
= (info->disassembler_options == NULL
|
= (disassembler_options == NULL
|
||||||
|| (strcmp (info->disassembler_options, "nocase") != 0));
|
|| (strcmp (disassembler_options, "nocase") != 0));
|
||||||
|
|
||||||
disdata->distype = distype;
|
disdata->distype = distype;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct cris_spec_reg *
|
static const struct cris_spec_reg *
|
||||||
@ -2736,9 +2729,10 @@ static int
|
|||||||
print_insn_cris_with_register_prefix (bfd_vma vma,
|
print_insn_cris_with_register_prefix (bfd_vma vma,
|
||||||
disassemble_info *info)
|
disassemble_info *info)
|
||||||
{
|
{
|
||||||
if (info->private_data == NULL
|
struct cris_disasm_data disdata;
|
||||||
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
|
info->private_data = &disdata;
|
||||||
return -1;
|
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||||
|
cris_dis_v0_v10);
|
||||||
return print_insn_cris_generic (vma, info, true);
|
return print_insn_cris_generic (vma, info, true);
|
||||||
}
|
}
|
||||||
/* Disassemble, prefixing register names with `$'. CRIS v32. */
|
/* Disassemble, prefixing register names with `$'. CRIS v32. */
|
||||||
@ -2747,9 +2741,10 @@ static int
|
|||||||
print_insn_crisv32_with_register_prefix (bfd_vma vma,
|
print_insn_crisv32_with_register_prefix (bfd_vma vma,
|
||||||
disassemble_info *info)
|
disassemble_info *info)
|
||||||
{
|
{
|
||||||
if (info->private_data == NULL
|
struct cris_disasm_data disdata;
|
||||||
&& !cris_parse_disassembler_options (info, cris_dis_v32))
|
info->private_data = &disdata;
|
||||||
return -1;
|
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||||
|
cris_dis_v32);
|
||||||
return print_insn_cris_generic (vma, info, true);
|
return print_insn_cris_generic (vma, info, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2761,9 +2756,10 @@ static int
|
|||||||
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
|
print_insn_crisv10_v32_with_register_prefix (bfd_vma vma,
|
||||||
disassemble_info *info)
|
disassemble_info *info)
|
||||||
{
|
{
|
||||||
if (info->private_data == NULL
|
struct cris_disasm_data disdata;
|
||||||
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
|
info->private_data = &disdata;
|
||||||
return -1;
|
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||||
|
cris_dis_common_v10_v32);
|
||||||
return print_insn_cris_generic (vma, info, true);
|
return print_insn_cris_generic (vma, info, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2773,9 +2769,10 @@ static int
|
|||||||
print_insn_cris_without_register_prefix (bfd_vma vma,
|
print_insn_cris_without_register_prefix (bfd_vma vma,
|
||||||
disassemble_info *info)
|
disassemble_info *info)
|
||||||
{
|
{
|
||||||
if (info->private_data == NULL
|
struct cris_disasm_data disdata;
|
||||||
&& !cris_parse_disassembler_options (info, cris_dis_v0_v10))
|
info->private_data = &disdata;
|
||||||
return -1;
|
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||||
|
cris_dis_v0_v10);
|
||||||
return print_insn_cris_generic (vma, info, false);
|
return print_insn_cris_generic (vma, info, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2785,9 +2782,10 @@ static int
|
|||||||
print_insn_crisv32_without_register_prefix (bfd_vma vma,
|
print_insn_crisv32_without_register_prefix (bfd_vma vma,
|
||||||
disassemble_info *info)
|
disassemble_info *info)
|
||||||
{
|
{
|
||||||
if (info->private_data == NULL
|
struct cris_disasm_data disdata;
|
||||||
&& !cris_parse_disassembler_options (info, cris_dis_v32))
|
info->private_data = &disdata;
|
||||||
return -1;
|
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||||
|
cris_dis_v32);
|
||||||
return print_insn_cris_generic (vma, info, false);
|
return print_insn_cris_generic (vma, info, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2798,9 +2796,10 @@ static int
|
|||||||
print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
|
print_insn_crisv10_v32_without_register_prefix (bfd_vma vma,
|
||||||
disassemble_info *info)
|
disassemble_info *info)
|
||||||
{
|
{
|
||||||
if (info->private_data == NULL
|
struct cris_disasm_data disdata;
|
||||||
&& !cris_parse_disassembler_options (info, cris_dis_common_v10_v32))
|
info->private_data = &disdata;
|
||||||
return -1;
|
cris_parse_disassembler_options (&disdata, info->disassembler_options,
|
||||||
|
cris_dis_common_v10_v32);
|
||||||
return print_insn_cris_generic (vma, info, false);
|
return print_insn_cris_generic (vma, info, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user