mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-26 06:30:33 +00:00
Fix some memory leaks caused by buggy macros for reference counting
This commit is contained in:
parent
cd15bdb1e8
commit
b446f7ab47
@ -3283,6 +3283,9 @@ R_API void r_core_fini(RCore *c) {
|
||||
r_core_task_scheduler_fini (&c->tasks);
|
||||
c->rcmd = r_cmd_free (c->rcmd);
|
||||
r_list_free (c->cmd_descriptors);
|
||||
r_unref (c->print->config);
|
||||
r_unref (c->anal->reg->config);
|
||||
r_unref (c->anal->config);
|
||||
r_anal_free (c->anal);
|
||||
r_asm_free (c->rasm);
|
||||
c->rasm = NULL;
|
||||
|
@ -758,10 +758,10 @@ typedef int RRef;
|
||||
|
||||
#define R_REF_NAME refcount
|
||||
#define r_ref(x) ((x)->R_REF_NAME++, (x));
|
||||
#define r_ref_set(x,y) do { if(x) { (x)->R_REF_NAME--; } (x)=(y); (x)->R_REF_NAME++;} while(0)
|
||||
#define r_ref_init(x,y) (x)->R_REF_NAME = 1;(x)->free = (void *)(y)
|
||||
// #define r_unref(x) { assert (x->R_REF_NAME > 0); if (!--(x->R_REF_NAME)) { x->free(x); } }
|
||||
#define r_unref(x) { if (x->R_REF_NAME > 0 && !--(x->R_REF_NAME)) { x->free(x); } }
|
||||
#define r_unref(x) { if ((x) != NULL && (x)->R_REF_NAME > 0 && !--((x)->R_REF_NAME)) { (x)->free(x); (x) = NULL; } }
|
||||
#define r_ref_set(x,y) do { if ((x) != (y) && (x) != NULL) { r_unref(x); } (x)=(y); (y)->R_REF_NAME++; } while(0)
|
||||
|
||||
#define R_REF_TYPE RRef R_REF_NAME; void (*free)(void*)
|
||||
#define R_REF_FUNCTIONS(s, n) \
|
||||
|
Loading…
Reference in New Issue
Block a user