Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix few low hanging memleak fruits #23915

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions libr/anal/vtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ R_API void r_anal_vtables_list(RAnal *anal, int rad) {

if (rad == 'j') {
PJ *pj = pj_new ();
if (!pj) {
return;
}
pj_a (pj);
r_list_foreach (vtables, vtableIter, table) {
pj_o (pj);
Expand Down
4 changes: 2 additions & 2 deletions libr/include/r_util/pj.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ typedef struct pj_t {
} PJ;

/* lifecycle */
R_API PJ *pj_new(void);
R_API PJ *pj_new_with_encoding(PJEncodingStr str_encoding, PJEncodingNum num_encoding);
R_API R_NONNULL PJ *pj_new(void);
R_API R_NONNULL PJ *pj_new_with_encoding(PJEncodingStr str_encoding, PJEncodingNum num_encoding);
R_API void pj_free(PJ *j);
R_API void pj_reset(PJ *j); // clear the pj contents, but keep the buffer allocated to re-use it
R_API char *pj_drain(PJ *j);
Expand Down
2 changes: 1 addition & 1 deletion libr/io/io_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,6 @@ R_API bool r_io_map_setattr(RIOMap *map, ut32 type, ut32 flags) {
}

R_API char *r_io_map_getattr(RIOMap *map) {
RStrBuf *sb = r_strbuf_new ("");
ut32 maptype = map->meta & 0xffff;
ut32 mapflag = (map->meta > 16) & 0xffff;
if (maptype >= R_IO_MAP_META_TYPE_LAST) {
Expand All @@ -829,6 +828,7 @@ R_API char *r_io_map_getattr(RIOMap *map) {
if (mapflag >= R_IO_MAP_META_FLAG_LAST) {
return false;
}
RStrBuf *sb = r_strbuf_new ("");
r_strbuf_append (sb, metatypename[maptype]);
int i = 0;
for (i = 0; i < 16; i++) {
Expand Down
14 changes: 6 additions & 8 deletions libr/util/pj.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ static void pj_comma(PJ *j) {
j->is_key = false;
}

R_API PJ *pj_new(void) {
R_API R_NONNULL PJ *pj_new(void) {
PJ *j = R_NEW0 (PJ);
if (j) {
r_strbuf_init (&j->sb);
j->is_first = true;
j->comma = ",";
j->str_encoding = PJ_ENCODING_STR_DEFAULT;
j->num_encoding = PJ_ENCODING_NUM_DEFAULT;
}
r_strbuf_init (&j->sb);
j->is_first = true;
j->comma = ",";
j->str_encoding = PJ_ENCODING_STR_DEFAULT;
j->num_encoding = PJ_ENCODING_NUM_DEFAULT;
return j;
}

Expand Down
Loading