diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-04-24 22:35:20 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-04-24 22:35:20 (GMT) |
commit | a585058f1469fe89a23562567e478d9de6f16b8f (patch) | |
tree | 43266c49104b4179fafe16cde6048e79a3e23bdc | |
parent | ec14d57b5224166c9665f85f406745ec2f4f5a0f (diff) |
Locked the register singleton list during updates.
-rw-r--r-- | plugins/dalvik/register.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/dalvik/register.c b/plugins/dalvik/register.c index 51abe2f..0833650 100644 --- a/plugins/dalvik/register.c +++ b/plugins/dalvik/register.c @@ -86,6 +86,7 @@ GDalvikRegister *_g_dalvik_register_new(uint16_t); /* Conservation des registres utilisés */ static GDalvikRegister **_dalvik_registers = NULL; static uint16_t _dreg_count = 0; +G_LOCK_DEFINE_STATIC(_dreg_mutex); /* Fournit le singleton associé à un registre Dalvik. */ @@ -362,6 +363,8 @@ static GDalvikRegister *get_dalvik_register(uint16_t index) GDalvikRegister *result; /* Structure à retourner */ uint16_t i; /* Boucle de parcours */ + G_LOCK(_dreg_mutex); + if (index >= _dreg_count) { _dalvik_registers = realloc(_dalvik_registers, (index + 1) * sizeof(GDalvikRegister *)); @@ -378,6 +381,8 @@ static GDalvikRegister *get_dalvik_register(uint16_t index) result = _dalvik_registers[index]; + G_UNLOCK(_dreg_mutex); + g_object_ref(G_OBJECT(result)); return result; @@ -401,6 +406,8 @@ void clean_dalvik_register_cache(void) { uint16_t i; /* Boucle de parcours */ + G_LOCK(_dreg_mutex); + for (i = 0; i < _dreg_count; i++) g_object_unref(G_OBJECT(_dalvik_registers[i])); @@ -410,4 +417,6 @@ void clean_dalvik_register_cache(void) _dalvik_registers = NULL; _dreg_count = 0; + G_UNLOCK(_dreg_mutex); + } |