Remove all char* casts in free ##cleanup
* Fix dwarf demangle logic * dwarf_process.c * type.c * pyc_dis.c * dex.c * emit_arm.c * qjs_core.c * axml.c * engine.c * cconfig.c * core.c * asn1_str.c
This commit is contained in:
parent
57812e2471
commit
06a8789780
|
@ -16,8 +16,8 @@ typedef struct dwarf_parse_context_t {
|
|||
|
||||
typedef struct dwarf_function_t {
|
||||
ut64 addr;
|
||||
const char *name;
|
||||
const char *signature;
|
||||
char *name;
|
||||
char *signature;
|
||||
bool is_external;
|
||||
bool is_method;
|
||||
bool is_virtual;
|
||||
|
@ -1611,12 +1611,12 @@ static void parse_function(Context *ctx, ut64 idx) {
|
|||
switch (die->attr_values[i].attr_name) {
|
||||
case DW_AT_name:
|
||||
if (!get_linkage_name || !has_linkage_name) {
|
||||
fcn.name = val->string.content;
|
||||
fcn.name = strdup (val->string.content);
|
||||
}
|
||||
break;
|
||||
case DW_AT_linkage_name:
|
||||
case DW_AT_MIPS_linkage_name:
|
||||
fcn.name = val->string.content;
|
||||
fcn.name = strdup (val->string.content);
|
||||
has_linkage_name = true;
|
||||
break;
|
||||
case DW_AT_low_pc:
|
||||
|
@ -1627,7 +1627,7 @@ static void parse_function(Context *ctx, ut64 idx) {
|
|||
{
|
||||
RBinDwarfDie *spec_die = ht_up_find (ctx->die_map, val->reference, NULL);
|
||||
if (spec_die) {
|
||||
fcn.name = get_specification_die_name (spec_die); /* I assume that if specification has a name, this DIE hasn't */
|
||||
fcn.name = strdup (get_specification_die_name (spec_die)); /* I assume that if specification has a name, this DIE hasn't */
|
||||
get_spec_die_type (ctx, spec_die, &ret_type);
|
||||
}
|
||||
break;
|
||||
|
@ -1675,15 +1675,21 @@ static void parse_function(Context *ctx, ut64 idx) {
|
|||
if (ret_type.len == 0) { /* DW_AT_type is omitted in case of `void` ret type */
|
||||
r_strbuf_append (&ret_type, "void");
|
||||
}
|
||||
|
||||
r_warn_if_fail (ctx->lang);
|
||||
char *new_name = ctx->anal->binb.demangle
|
||||
? ctx->anal->binb.demangle (NULL, ctx->lang, fcn.name, fcn.addr, false): NULL;
|
||||
fcn.name = new_name ? new_name : strdup (fcn.name);
|
||||
if (ctx->anal->binb.demangle) {
|
||||
char *mangled_name = fcn.name;
|
||||
char *demangled_name = ctx->anal->binb.demangle (NULL, ctx->lang, mangled_name, fcn.addr, false);
|
||||
if (demangled_name) {
|
||||
fcn.name = demangled_name;
|
||||
free (mangled_name);
|
||||
}
|
||||
}
|
||||
fcn.signature = r_str_newf ("%s %s(%s);", r_strbuf_get (&ret_type), fcn.name, r_strbuf_get (&args));
|
||||
sdb_save_dwarf_function (&fcn, variables, ctx->sdb);
|
||||
|
||||
free ((char *)fcn.signature);
|
||||
free ((char *)fcn.name);
|
||||
free (fcn.signature);
|
||||
free (fcn.name);
|
||||
|
||||
RListIter *iter;
|
||||
Variable *var;
|
||||
|
|
|
@ -104,21 +104,21 @@ R_API RList *r_anal_types_from_fcn(RAnal *anal, RAnalFunction *fcn) {
|
|||
R_IPI void enum_type_case_free(void *e, void *user) {
|
||||
(void)user;
|
||||
RAnalEnumCase *cas = e;
|
||||
free ((char *)cas->name);
|
||||
free (cas->name);
|
||||
}
|
||||
|
||||
R_IPI void struct_type_member_free(void *e, void *user) {
|
||||
(void)user;
|
||||
RAnalStructMember *member = e;
|
||||
free ((char *)member->name);
|
||||
free ((char *)member->type);
|
||||
free (member->name);
|
||||
free (member->type);
|
||||
}
|
||||
|
||||
R_IPI void union_type_member_free(void *e, void *user) {
|
||||
(void)user;
|
||||
RAnalUnionMember *member = e;
|
||||
free ((char *)member->name);
|
||||
free ((char *)member->type);
|
||||
free (member->name);
|
||||
free (member->type);
|
||||
}
|
||||
|
||||
static RAnalBaseType *get_enum_type(RAnal *anal, const char *sname) {
|
||||
|
|
|
@ -63,7 +63,7 @@ int r_pyc_disasm(RAnalOp *opstruct, const ut8 *code, RList *cobjs, RList *intern
|
|||
char *nm = r_str_newf ("%s %s", opstruct->mnemonic, arg);
|
||||
free (opstruct->mnemonic);
|
||||
opstruct->mnemonic = nm;
|
||||
free ((char *)arg);
|
||||
free (arg);
|
||||
}
|
||||
} else if (ops->bits == 8) {
|
||||
i += 1;
|
||||
|
|
|
@ -55,7 +55,7 @@ static char *getstr(RBinDexObj *bin, int idx) {
|
|||
}
|
||||
|
||||
|
||||
static const char *className(RBinDexObj *dex, int idx) {
|
||||
static char *className(RBinDexObj *dex, int idx) {
|
||||
if (idx < 0 || idx >= dex->header.types_size) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ static void readAnnotation(RBinDexObj *dex, bool readVisibility) {
|
|||
if (typeSize < 0 || typeSize > 10000) {
|
||||
return;
|
||||
}
|
||||
const char *typeString = className (dex, typeIndex);
|
||||
char *typeString = className (dex, typeIndex);
|
||||
if (typeString) {
|
||||
bprintf (" TypeSize: %d %d (%s)\n", (int)typeIndex, (int)typeSize, typeString);
|
||||
for (i = 0; i < typeSize; i++) {
|
||||
|
@ -196,7 +196,7 @@ static void readAnnotation(RBinDexObj *dex, bool readVisibility) {
|
|||
r_buf_seek (dex->b, at, R_BUF_SET);
|
||||
parseValue (dex);
|
||||
}
|
||||
free ((char *)typeString);
|
||||
free (typeString);
|
||||
} else {
|
||||
bprintf (" TypeSize: %d %d (?)\n", (int)typeIndex, (int)typeSize);
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ RBinDexObj *r_bin_dex_new_buf(RBuffer *buf, bool verbose) {
|
|||
continue;
|
||||
}
|
||||
int j;
|
||||
const char *cn = className (dex, dex->classes[i].class_id);
|
||||
char *cn = className (dex, dex->classes[i].class_id);
|
||||
r_buf_seek (dex->b, at, R_BUF_SET);
|
||||
ut32 classAnnotationsOffset = r_buf_read_le32 (dex->b);
|
||||
ut32 fieldsCount = r_buf_read_le32 (dex->b);
|
||||
|
@ -498,7 +498,7 @@ RBinDexObj *r_bin_dex_new_buf(RBuffer *buf, bool verbose) {
|
|||
bprintf (" annotatedMethodCount %d\n", annotatedMethodsCount);
|
||||
bprintf (" annotatedParametersCount %d\n", annotatedParametersCount);
|
||||
|
||||
free ((char *)cn);
|
||||
free (cn);
|
||||
|
||||
if (fieldsCount == UT32_MAX || annotatedMethodsCount == UT32_MAX || annotatedParametersCount == UT32_MAX || classAnnotationsOffset == UT32_MAX) {
|
||||
continue;
|
||||
|
|
|
@ -2572,7 +2572,11 @@ static bool cb_scrstrconv(void *user, void *data) {
|
|||
}
|
||||
return false;
|
||||
} else {
|
||||
#if R2_590
|
||||
free (core->print->strconv_mode);
|
||||
#else
|
||||
free ((char *)core->print->strconv_mode);
|
||||
#endif
|
||||
core->print->strconv_mode = strdup (node->value);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -4194,7 +4194,11 @@ R_API void r_core_autocomplete_free(RCoreAutocomplete *obj) {
|
|||
obj->subcmds[i] = NULL;
|
||||
}
|
||||
free (obj->subcmds);
|
||||
free ((char*) obj->cmd);
|
||||
#if R2_590
|
||||
free (obj->cmd);
|
||||
#else
|
||||
free ((char *)obj->cmd);
|
||||
#endif
|
||||
free (obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -83,6 +83,7 @@ static void emit_syscall_args(REgg *egg, int nargs) {
|
|||
}
|
||||
|
||||
static void emit_set_string(REgg *egg, const char *dstvar, const char *str, int j) {
|
||||
char *str_escaped;
|
||||
int rest, off = 0;
|
||||
off = strlen (str) + 1;
|
||||
rest = (off % 4);
|
||||
|
@ -94,8 +95,9 @@ static void emit_set_string(REgg *egg, const char *dstvar, const char *str, int
|
|||
// XXX: does not handle \n and so on.. must use r_util
|
||||
// use r_str_escape to handle \n
|
||||
// do not forget mem leak
|
||||
r_egg_printf (egg, ".string \"%s\"\n", str = r_str_escape (str));
|
||||
free ((char *) str);
|
||||
str_escaped = r_str_escape (str);
|
||||
r_egg_printf (egg, ".string \"%s\"\n", str);
|
||||
free (str_escaped);
|
||||
if (rest) {
|
||||
r_egg_printf (egg, ".fill %d, 1, 0\n", (rest));
|
||||
}
|
||||
|
|
|
@ -188,7 +188,11 @@ typedef enum r_core_autocomplete_types_t {
|
|||
} RCoreAutocompleteType;
|
||||
|
||||
typedef struct r_core_autocomplete_t {
|
||||
#if R2_590
|
||||
char *cmd;
|
||||
#else
|
||||
const char* cmd;
|
||||
#endif
|
||||
int length;
|
||||
int n_subcmds;
|
||||
bool locked;
|
||||
|
|
|
@ -62,7 +62,7 @@ extern "C" {
|
|||
|
||||
typedef struct r_asn1_string_t {
|
||||
ut32 length;
|
||||
const char *string;
|
||||
char *string;
|
||||
bool allocated;
|
||||
} RASN1String;
|
||||
|
||||
|
|
|
@ -141,7 +141,11 @@ typedef struct r_print_t {
|
|||
int lines_abs;
|
||||
bool esc_bslash;
|
||||
bool wide_offsets;
|
||||
#if R2_590
|
||||
char *strconv_mode;
|
||||
#else
|
||||
const char *strconv_mode;
|
||||
#endif
|
||||
RList *vars;
|
||||
char io_unalloc_ch;
|
||||
bool show_offset;
|
||||
|
|
|
@ -184,7 +184,7 @@ static JSValue r2plugin_core(JSContext *ctx, JSValueConst this_val, int argc, JS
|
|||
size_t namelen;
|
||||
const char *nameptr = JS_ToCStringLen2 (ctx, &namelen, name, false);
|
||||
if (nameptr) {
|
||||
ap->name = strdup (nameptr);
|
||||
ap->name = nameptr;
|
||||
} else {
|
||||
R_LOG_WARN ("r2.plugin requires the function to return an object with the `name` field");
|
||||
return JS_NewBool (ctx, false);
|
||||
|
@ -209,7 +209,6 @@ static JSValue r2plugin_core(JSContext *ctx, JSValueConst this_val, int argc, JS
|
|||
QjsContext *qc = qjsctx_find (core, ap->name);
|
||||
if (qc) {
|
||||
R_LOG_WARN ("r2.plugin with name %s is already registered", ap->name);
|
||||
free ((char*)ap->name);
|
||||
free (ap);
|
||||
// return JS_ThrowRangeError (ctx, "r2.plugin core already registered (only one exists)");
|
||||
return JS_NewBool (ctx, false);
|
||||
|
|
|
@ -14,7 +14,7 @@ R_API RASN1String *r_asn1_create_string(const char *string, bool allocated, ut32
|
|||
if (s) {
|
||||
s->allocated = allocated;
|
||||
s->length = length;
|
||||
s->string = string;
|
||||
s->string = (char *)string;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
@ -313,7 +313,11 @@ R_API RASN1String *r_asn1_stringify_oid(const ut8* buffer, ut32 length) {
|
|||
R_API void r_asn1_string_free(RASN1String* str) {
|
||||
if (str) {
|
||||
if (str->allocated) {
|
||||
free ((char*) str->string);
|
||||
#if R2_590
|
||||
free (str->string);
|
||||
#else
|
||||
free ((char *)str->string);
|
||||
#endif
|
||||
}
|
||||
free (str);
|
||||
}
|
||||
|
|
|
@ -264,22 +264,22 @@ static bool dump_element(PJ *pj, RStrBuf *sb, string_pool_t *pool, namespace_t *
|
|||
for (i = 0; i < count; i++) {
|
||||
attribute_t a = element->attributes[i];
|
||||
ut32 key_index = r_read_le32 (&a.name);
|
||||
const char *key = (const char *)string_lookup (pool, data, data_size, key_index, NULL);
|
||||
bool resource_key = false;
|
||||
char *key = string_lookup (pool, data, data_size, key_index, NULL);
|
||||
// If the key is empty, it is a cached resource name
|
||||
if (key && *key == '\0') {
|
||||
free ((char *)key);
|
||||
key = "null";
|
||||
resource_key = true;
|
||||
if (R_STR_ISEMPTY (key)) {
|
||||
R_FREE (key);
|
||||
if (resource_map && key_index < resource_map_length) {
|
||||
ut32 resource = r_read_le32 (&resource_map[key_index]);
|
||||
if (resource >= 0x1010000) {
|
||||
resource -= 0x1010000;
|
||||
if (resource < ANDROID_ATTRIBUTE_NAMES_SIZE) {
|
||||
key = ANDROID_ATTRIBUTE_NAMES[resource];
|
||||
key = strdup (ANDROID_ATTRIBUTE_NAMES[resource]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!key) {
|
||||
key = strdup ("null");
|
||||
}
|
||||
}
|
||||
char *value = resource_value (pool, data, data_size, &a.value);
|
||||
// If there is a namespace on the value, and there is an active
|
||||
|
@ -302,9 +302,6 @@ static bool dump_element(PJ *pj, RStrBuf *sb, string_pool_t *pool, namespace_t *
|
|||
if (i != count - 1) {
|
||||
r_strbuf_append (sb, " ");
|
||||
}
|
||||
if (!resource_key) {
|
||||
free ((char *)key);
|
||||
}
|
||||
free (value);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -286,8 +286,8 @@ static int matcher(struct re_guts *g, char *string, size_t nmatch, RRegexMatch p
|
|||
}
|
||||
}
|
||||
|
||||
free ((char *)m->pmatch);
|
||||
free ((char *)m->lastpos);
|
||||
free (m->pmatch);
|
||||
free (m->lastpos);
|
||||
STATETEARDOWN (m);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue