From 64224ffe7d6dc649bdde858ea5c949444eeaa111 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 29 Dec 2015 21:15:04 +0100 Subject: Protected all accesses to the symbols list using read locks. --- ChangeLog | 5 +++++ src/format/format.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index eb972c0..e4061e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 15-12-29 Cyrille Bagard + * src/format/format.c: + Protect all accesses to the symbols list using read locks. + +15-12-29 Cyrille Bagard + * plugins/python/welcome/version.py: Avoid to crash when the Internet is not reachable. diff --git a/src/format/format.c b/src/format/format.c index 323e006..63c4deb 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -310,6 +310,7 @@ static void _g_binary_format_remove_symbol(GBinFormat *format, size_t index) /** * TODO : envoyer un signal pour avertir les opérandes concernées. + * TODO : vérifier les conditions d'accès (verrou). */ symbol = format->symbols[index]; @@ -601,6 +602,8 @@ bool g_binary_format_find_symbol_by_label(const GBinFormat *format, const char * result = false; + g_rw_lock_reader_lock(&format->syms_lock); + for (i = 0; i < format->symbols_count && !result; i++) { cur_lbl = g_binary_symbol_get_label(format->symbols[i]); @@ -617,6 +620,8 @@ bool g_binary_format_find_symbol_by_label(const GBinFormat *format, const char * } + g_rw_lock_reader_unlock(&format->syms_lock); + return result; } @@ -646,8 +651,12 @@ static bool _g_binary_format_find_symbol(const GBinFormat *format, const vmpa2t *symbol = NULL; /* TODO : vérifier les doublons côtés appelants */ + g_rw_lock_reader_lock(&format->syms_lock); + found = bsearch(addr, format->symbols, format->symbols_count, sizeof(GBinSymbol *), fn); + g_rw_lock_reader_unlock(&format->syms_lock); + if (found != NULL) { *symbol = *(GBinSymbol **)found; @@ -756,6 +765,10 @@ bool g_binary_format_find_next_symbol_at(const GBinFormat *format, const vmpa2t *symbol = NULL; + g_rw_lock_reader_lock(&format->syms_lock); + + /* TODO : ajouter un peu de dichotomie ici ! */ + for (i = 0; i < format->symbols_count && !result; i++) { range = g_binary_symbol_get_range(format->symbols[i]); @@ -771,6 +784,8 @@ bool g_binary_format_find_next_symbol_at(const GBinFormat *format, const vmpa2t } + g_rw_lock_reader_unlock(&format->syms_lock); + return result; } -- cgit v0.11.2-87-g4458