Fix RStrBuf memleak in afta (#11251)

This commit is contained in:
Fangrui Song 2018-08-26 05:16:14 -07:00 committed by radare
parent 05fd10fd53
commit 019491bcbc
3 changed files with 13 additions and 9 deletions

View File

@ -183,7 +183,7 @@ static void var_add_range (RAnal *a, RAnalVar *var, int cond, ut64 val) {
sdb_array_append_num (ADB, key, val, 0);
}
R_API char *var_get_constraint (RAnal *a, RAnalVar *var) {
R_API RStrBuf *var_get_constraint (RAnal *a, RAnalVar *var) {
const char *key = RKEY (var->addr, var->kind, var->delta);
int i, n = sdb_array_length (ADB, key);
bool low = false, high = false;
@ -225,7 +225,7 @@ R_API char *var_get_constraint (RAnal *a, RAnalVar *var) {
high = false;
}
}
return r_strbuf_get (sb);
return sb;
}
static RList *parse_format(RCore *core, char *fmt) {

View File

@ -1407,14 +1407,17 @@ static ut32 tmp_get_realsize (RAnalFunction *f) {
static void ds_show_functions_argvar(RDisasmState *ds, RAnalVar *var, const char *base, bool is_var, char sign) {
int delta = sign == '+' ? var->delta : -var->delta;
const char *pfx = is_var ? "var" : "arg";
char *constr = NULL;
const char *pfx = is_var ? "var" : "arg", *constr = NULL;
RStrBuf *constr_buf = NULL;
bool cond = false;
if (ds->core && ds->core->anal) {
constr = var_get_constraint (ds->core->anal, var);
}
if (constr && *constr) {
cond = true;
constr_buf = var_get_constraint (ds->core->anal, var);
if (constr_buf) {
constr = r_strbuf_get (constr_buf);
if (constr[0]) {
cond = true;
}
}
}
r_cons_printf ("%s%s %s%s%s%s %s%s%s%s@ %s%c0x%x", COLOR_ARG (ds, color_func_var), pfx,
COLOR_ARG (ds, color_func_var_type), var->type,
@ -1424,6 +1427,7 @@ static void ds_show_functions_argvar(RDisasmState *ds, RAnalVar *var, const char
cond? constr: "",
cond? "} ":"",
base, sign, delta);
r_strbuf_free (constr_buf);
}
static void printVarSummary(RDisasmState *ds, RList *list) {

View File

@ -510,7 +510,7 @@ R_API RList* r_core_anal_cycles (RCore *core, int ccl);
/*tp.c*/
R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn);
R_API char *var_get_constraint (RAnal *a, RAnalVar *var);
R_API RStrBuf *var_get_constraint (RAnal *a, RAnalVar *var);
/* asm.c */
typedef struct r_core_asm_hit {