Fix more memleaks

This commit is contained in:
pancake 2018-03-14 15:31:08 +01:00
parent 0feefceab3
commit dc74fbd746
6 changed files with 28 additions and 24 deletions

View File

@ -186,6 +186,7 @@ R_API void r_cons_pal_free () {
R_FREE (*color);
}
}
R_FREE (r_cons_singleton ()->pal.rainbow);
}
R_API void r_cons_pal_random () {

View File

@ -22,21 +22,8 @@ static const char *help_msg_g[] = {
NULL
};
static RList *configList = NULL;
static void cmd_egg_init(RCore *core) {
DEFINE_CMD_DESCRIPTOR (core, g);
if (!(configList = r_list_new ())) {
return;
}
r_list_append (configList, "egg.shellcode");
r_list_append (configList, "egg.encoder");
r_list_append (configList, "egg.padding");
r_list_append (configList, "key");
r_list_append (configList, "cmd");
r_list_append (configList, "suid");
}
static void cmd_egg_option(REgg *egg, const char *key, const char *input) {
@ -60,7 +47,7 @@ static void showBuffer(RBuffer *b) {
for (i = 0; i < b->length; i++) {
r_cons_printf ("%02x", b->buf[i]);
}
r_cons_printf ("\n");
r_cons_newline ();
}
}
@ -244,10 +231,19 @@ static int cmd_egg(void *data, const char *input) {
break;
case 'S': // "gS"
{
RListIter *iter;
char *p;
static const char *configList[] = {
"egg.shellcode",
"egg.encoder",
"egg.padding",
"key",
"cmd",
"suid",
NULL
};
r_cons_printf ("Configuration options\n");
r_list_foreach (configList, iter, p) {
int i;
for (i = 0; configList[i]; i++) {
const char *p = configList[i];
if (r_egg_option_get (egg, p)) {
r_cons_printf ("%s : %s\n", p, r_egg_option_get (egg, p));
} else {

View File

@ -2868,6 +2868,7 @@ dsmap {
#endif
#define P(x) (core->cons && core->cons->pal.x)? core->cons->pal.x
#if 0
static void disasm_recursive_old(RCore *core, ut64 addr, char type_print) {
bool push[512];
int pushes = 0;
@ -2983,6 +2984,8 @@ r_cons_printf ("base:\n");
}
#endif
}
#endif
static void disasm_recursive(RCore *core, ut64 addr, char type_print) {
RAnalOp aop = {0};
int ret;

View File

@ -1924,6 +1924,7 @@ R_API RCore *r_core_fini(RCore *c) {
// avoid double free
r_core_free_autocomplete (c);
R_FREE (c->cmdlog);
r_th_lock_free (c->lock);
R_FREE (c->lastsearch);
c->cons->pager = NULL;
r_core_task_join (c, NULL);

View File

@ -792,7 +792,11 @@ R_API int r_core_files_free(const RCore *core, RCoreFile *cf) {
R_API void r_core_file_free(RCoreFile *cf) {
int res = 1;
if (!cf || !cf->core) {
if (!cf) {
return;
}
if (!cf->core) {
free (cf);
return;
}
res = r_core_files_free (cf->core, cf);

View File

@ -1021,15 +1021,14 @@ R_API bool r_sys_tts(const char *txt, bool bg) {
return false;
}
static char *prefix = NULL;
static char prefix[128] = {0};
R_API const char *r_sys_prefix(const char *pfx) {
if (pfx) {
free (prefix);
prefix = strdup (pfx);
}
if (!prefix) {
prefix = strdup (R2_PREFIX);
if (strlen (pfx) >= sizeof (prefix) -1) {
return NULL;
}
r_str_ncpy (prefix, pfx, sizeof (prefix) - 1);
}
return prefix;
}