Fix memleak in ds_opstr_try_colorize() (#3741)
This commit is contained in:
parent
b9281cbc9c
commit
0a623e1589
1 changed files with 9 additions and 8 deletions
|
|
@ -889,23 +889,24 @@ static void __replaceImports(RzDisasmState *ds) {
|
|||
|
||||
static void ds_opstr_try_colorize(RzDisasmState *ds, bool print_color) {
|
||||
bool colorize_asm = print_color && ds->show_color && ds->colorop;
|
||||
if (!colorize_asm)
|
||||
if (!colorize_asm) {
|
||||
return;
|
||||
|
||||
}
|
||||
RzCore *core = ds->core;
|
||||
RzStrBuf bw_asm;
|
||||
rz_strbuf_init(&bw_asm);
|
||||
rz_strbuf_set(&bw_asm, ds->opstr ? ds->opstr : rz_asm_op_get_asm(&ds->asmop));
|
||||
core->print->colorize_opts.reset_bg = line_highlighted(ds);
|
||||
char *source = ds->opstr ? strdup(ds->opstr) : strdup(rz_asm_op_get_asm(&ds->asmop));
|
||||
RzStrBuf *bw_asm = rz_strbuf_new(source);
|
||||
RzAsmParseParam *param = rz_asm_get_parse_param(core->analysis->reg, ds->analysis_op.type);
|
||||
RzStrBuf *colored_asm = rz_asm_colorize_asm_str(bw_asm, core->print, param, ds->asmop.asm_toks);
|
||||
RzStrBuf *colored_asm = rz_asm_colorize_asm_str(&bw_asm, core->print, param, ds->asmop.asm_toks);
|
||||
free(param);
|
||||
rz_strbuf_free(bw_asm);
|
||||
rz_strbuf_fini(&bw_asm);
|
||||
if (!colored_asm) {
|
||||
return;
|
||||
}
|
||||
source = rz_strbuf_drain(colored_asm);
|
||||
char *new_opstr = rz_strbuf_drain(colored_asm);
|
||||
free(ds->opstr);
|
||||
ds->opstr = source;
|
||||
ds->opstr = new_opstr;
|
||||
}
|
||||
|
||||
static void ds_build_op_str(RzDisasmState *ds, bool print_color) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue