mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 02:23:58 +00:00
Fix memleaks in RCons.pal
This commit is contained in:
parent
2e8363fdb6
commit
35f573fe1f
2
Makefile
2
Makefile
@ -35,7 +35,7 @@ all: plugins.cfg libr/include/r_version.h
|
||||
.PHONY: libr/include/r_version.h
|
||||
libr/include/r_version.h:
|
||||
echo "#define R2_VERSION_COMMIT $(R2VC)" > $@.tmp
|
||||
cmp $@.tmp $@ 2> /dev/null || mv $@.tmp $@
|
||||
cmp $@.tmp $@ > /dev/null 2>&1 || mv $@.tmp $@
|
||||
|
||||
plugins.cfg:
|
||||
@if [ ! -e config-user.mk ]; then echo ; \
|
||||
|
@ -63,7 +63,7 @@ R_API char *r_cons_color_random(int bg) {
|
||||
case 14: return strdup (Color_GRAY);
|
||||
case 15: return strdup (Color_BGRAY);
|
||||
}
|
||||
return Color_RESET;
|
||||
return strdup (Color_RESET);
|
||||
}
|
||||
|
||||
R_API void r_cons_color (int fg, int r, int g, int b) {
|
||||
@ -160,7 +160,17 @@ R_API int r_cons_enable_mouse (const int enable) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static void r_cons_pal_null (){
|
||||
int i;
|
||||
RCons *cons = r_cons_singleton ();
|
||||
for (i = 0; i< R_CONS_PALETTE_LIST_SIZE; i++){
|
||||
cons->pal.list[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
R_API RCons *r_cons_new () {
|
||||
int i;
|
||||
I.refcnt++;
|
||||
if (I.refcnt != 1)
|
||||
return &I;
|
||||
@ -212,6 +222,7 @@ R_API RCons *r_cons_new () {
|
||||
I.pager = NULL; /* no pager by default */
|
||||
I.truecolor = 0;
|
||||
I.mouse = 0;
|
||||
r_cons_pal_null ();
|
||||
r_cons_pal_init (NULL);
|
||||
r_cons_rgb_init ();
|
||||
r_cons_reset ();
|
||||
@ -222,6 +233,7 @@ R_API RCons *r_cons_free () {
|
||||
I.refcnt--;
|
||||
if (I.refcnt != 0)
|
||||
return NULL;
|
||||
r_cons_pal_free ();
|
||||
if (I.line) {
|
||||
r_line_free ();
|
||||
I.line = NULL;
|
||||
|
@ -2,6 +2,16 @@
|
||||
|
||||
#include <r_cons.h>
|
||||
|
||||
|
||||
R_API void r_cons_pal_free () {
|
||||
int i;
|
||||
RCons *cons = r_cons_singleton ();
|
||||
for (i = 0; i < R_CONS_PALETTE_LIST_SIZE; i++) {
|
||||
if (cons->pal.list[i])
|
||||
R_FREE (cons->pal.list[i]);
|
||||
}
|
||||
}
|
||||
|
||||
R_API void r_cons_pal_init(const char *foo) {
|
||||
RCons *cons = r_cons_singleton ();
|
||||
memset (&cons->pal, 0, sizeof (cons->pal));
|
||||
@ -52,7 +62,8 @@ R_API void r_cons_pal_init(const char *foo) {
|
||||
cons->pal.gui_background = Color_BLACK;
|
||||
cons->pal.gui_alt_background = Color_WHITE;
|
||||
cons->pal.gui_border = Color_BLACK;
|
||||
|
||||
|
||||
r_cons_pal_free ();
|
||||
cons->pal.list[0] = strdup (Color_RED);
|
||||
cons->pal.list[1] = strdup (Color_YELLOW);
|
||||
cons->pal.list[2] = strdup (Color_BGREEN);
|
||||
@ -103,6 +114,8 @@ R_API void r_cons_pal_random() {
|
||||
r_cons_pal_set (k, val);
|
||||
}
|
||||
for (i=0; i<R_CONS_PALETTE_LIST_SIZE; i++) {
|
||||
if (cons->pal.list[i])
|
||||
R_FREE (cons->pal.list[i]);
|
||||
cons->pal.list[i] = r_cons_color_random (0);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ R_API ut64 r_core_anal_address (RCore *core, ut64 addr) {
|
||||
int _rwx = -1;
|
||||
RIOSection *ios;
|
||||
RListIter *iter;
|
||||
if (!core->io) break;
|
||||
if (core->io) {
|
||||
// sections
|
||||
r_list_foreach (core->io->sections, iter, ios) {
|
||||
if (addr >= ios->vaddr && addr < (ios->vaddr+ios->vsize)) {
|
||||
@ -89,6 +89,7 @@ R_API ut64 r_core_anal_address (RCore *core, ut64 addr) {
|
||||
types |= R_ANAL_ADDR_TYPE_STACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_rwx != -1) {
|
||||
if (_rwx & R_IO_EXEC)
|
||||
types |= R_ANAL_ADDR_TYPE_EXEC;
|
||||
|
@ -373,6 +373,7 @@ R_API int r_cons_eof(void);
|
||||
|
||||
R_API int r_cons_palette_init(const unsigned char *pal);
|
||||
R_API int r_cons_pal_set (const char *key, const char *val);
|
||||
R_API void r_cons_pal_free(void);
|
||||
R_API void r_cons_pal_init(const char *foo);
|
||||
R_API char *r_cons_pal_parse(const char *str);
|
||||
R_API void r_cons_pal_random(void);
|
||||
|
Loading…
Reference in New Issue
Block a user