From c13ede076924ca6675b3b1a254fb3a433fc7ccf3 Mon Sep 17 00:00:00 2001 From: pancake Date: Wed, 26 Jun 2024 08:40:27 +0200 Subject: [PATCH] Fix null deref, memleaks and portability regression --- libr/cons/hud.c | 1 + libr/core/panels.c | 4 ++-- libr/util/token.c | 6 +++--- test/db/tools/token | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libr/cons/hud.c b/libr/cons/hud.c index 080942bd4833e..a1d96e152bd75 100644 --- a/libr/cons/hud.c +++ b/libr/cons/hud.c @@ -490,6 +490,7 @@ static char *r_cons_message_multiline(const char *msg) { r_cons_any_key (NULL); r_list_free (lines); free (s); + free (newmsg); return NULL; } diff --git a/libr/core/panels.c b/libr/core/panels.c index a6e936a6b4c2d..642b570b5c137 100644 --- a/libr/core/panels.c +++ b/libr/core/panels.c @@ -5159,7 +5159,7 @@ static void __add_menu(RCore *core, const char *parent, const char *name, RPanel } if (p_item == NULL) { R_LOG_WARN ("Cannot find panel %s", parent); - sleep (1); + r_sys_sleep (1); } item->n_sub = 0; item->selectedIndex = 0; @@ -5167,7 +5167,7 @@ static void __add_menu(RCore *core, const char *parent, const char *name, RPanel item->sub = NULL; item->cb = cb; item->p = R_NEW0 (RPanel); - if (item->p) { + if (item->p && p_item) { item->p->model = R_NEW0 (RPanelModel); item->p->view = R_NEW0 (RPanelView); if (item->p->model && item->p->view) { diff --git a/libr/util/token.c b/libr/util/token.c index eebc27d528d5c..4b49bca794dac 100644 --- a/libr/util/token.c +++ b/libr/util/token.c @@ -300,7 +300,7 @@ bool callback(RTokenizer *tok) { switch (tok->ch) { case '}': R_FREE (data->s); - // pj_end (data->pj); + pj_end (data->pj); pj_end (data->pj); break; } @@ -337,7 +337,7 @@ bool callback(RTokenizer *tok) { pj_end (data->pj); if (first) { first = false; - pj_ka (data->pj, "blocks"); + pj_ka (data->pj, "body"); } } } @@ -354,7 +354,7 @@ bool callback(RTokenizer *tok) { R_FREE (data->s); } // pj_ka (data->pj, "body"); - pj_a (data->pj); + //pj_a (data->pj); } else if (tok->ch == '(') { data->parlevel++; if (data->word) { diff --git a/test/db/tools/token b/test/db/tools/token index 9e58cf5e6c39b..4a454a748217a 100644 --- a/test/db/tools/token +++ b/test/db/tools/token @@ -55,7 +55,7 @@ EXPECT=<