Fix memleak in test_anal_block & test_io (#18153)

This commit is contained in:
Liumeo 2021-01-02 03:37:23 -05:00 committed by GitHub
parent 93166667da
commit 06b735441d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 1 deletions

View File

@ -123,6 +123,7 @@ static void cons_context_init(RConsContext *context, R_NULLABLE RConsContext *pa
}
static void cons_context_deinit(RConsContext *context) {
R_FREE (context->error);
r_stack_free (context->cons_stack);
context->cons_stack = NULL;
r_stack_free (context->break_stack);

View File

@ -35,6 +35,7 @@ R_API void r_line_free(void) {
// XXX: prompt out of the heap?
free ((void *)I.prompt);
I.prompt = NULL;
r_list_free (I.kill_ring);
r_line_hist_free ();
r_line_completion_fini (&I.completion);
}

View File

@ -76,6 +76,9 @@ R_API int r_io_cache_invalidate(RIO *io, ut64 from, ut64 to) {
io->cached = cached;
c->written = false;
r_pvector_remove_data (&io->cache, c);
free (c->data);
free (c->odata);
free (c);
invalidated++;
}
}

View File

@ -666,6 +666,7 @@ bool test_r_anal_block_chop_noreturn(void) {
r_anal_block_chop_noreturn (b, 0x111);
assert_invariants (anal);
r_anal_free (anal);
mu_end;
}

View File

@ -5,7 +5,6 @@ bool test_r_io_cache(void) {
RIO *io = r_io_new ();
r_io_open (io, "malloc://15", R_PERM_RW, 0);
r_io_write (io, (ut8 *)"ZZZZZZZZZZZZZZZ", 15);
r_io_cache_init (io);
mu_assert_false (r_io_cache_at (io, 0), "Cache shouldn't exist at 0");
mu_assert_false (r_io_cache_at (io, 10), "Cache shouldn't exist at 10");
mu_assert_true (r_io_cache_write (io, 0, (ut8 *)"AAAAA", 5), "Cache write at 0 failed");