diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2010-12-11 03:41:45 +0100 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2010-12-11 03:49:54 +0100 |
commit | fe7c270bddd681e3e56dc28beacf5be425c5e53e (patch) | |
tree | f992adb75f76b6e4b1d8a81c969daabc69285bba /src | |
parent | e6230576b7acd34d711c0314077a0428a4c8a82f (diff) | |
download | logdiag-fe7c270bddd681e3e56dc28beacf5be425c5e53e.tar.gz logdiag-fe7c270bddd681e3e56dc28beacf5be425c5e53e.tar.xz logdiag-fe7c270bddd681e3e56dc28beacf5be425c5e53e.zip |
Check for name collisions in symbol categories.
Diffstat (limited to 'src')
-rw-r--r-- | src/ld-library.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/ld-library.c b/src/ld-library.c index 6348bc6..09f68b5 100644 --- a/src/ld-library.c +++ b/src/ld-library.c @@ -249,9 +249,30 @@ load_category_cb (const gchar *base, const gchar *filename, gpointer userdata) static void load_category_symbol_cb (LdSymbol *symbol, gpointer user_data) { - /* TODO: Don't just add blindly, also check for name collisions. */ - ld_symbol_category_insert_child - (LD_SYMBOL_CATEGORY (user_data), G_OBJECT (symbol), -1); + const gchar *name; + LdSymbolCategory *cat; + const GSList *children, *iter; + + g_return_if_fail (LD_IS_SYMBOL (symbol)); + g_return_if_fail (LD_IS_SYMBOL_CATEGORY (user_data)); + + cat = LD_SYMBOL_CATEGORY (user_data); + name = ld_symbol_get_name (symbol); + + /* Check for name collisions with other symbols. */ + children = ld_symbol_category_get_children (cat); + for (iter = children; iter; iter = iter->next) + { + if (!LD_IS_SYMBOL (iter->data)) + continue; + if (!strcmp (name, ld_symbol_get_name (LD_SYMBOL (iter->data)))) + { + g_warning ("Attempted to insert multiple '%s' symbols into" + " category '%s'.", name, ld_symbol_category_get_name (cat)); + return; + } + } + ld_symbol_category_insert_child (cat, G_OBJECT (symbol), -1); } /* |