From: Vsevolod Stakhov Date: Sun, 1 May 2022 12:02:48 +0000 (+0100) Subject: [Minor] Another attempt to distinguish normal and virtual symbols X-Git-Tag: 3.3~287 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f8851d834a57f12b2070cbd027cb49dfcf1d320c;p=rspamd.git [Minor] Another attempt to distinguish normal and virtual symbols --- diff --git a/src/libserver/symcache/symcache_c.cxx b/src/libserver/symcache/symcache_c.cxx index af4d36432..7af45ac64 100644 --- a/src/libserver/symcache/symcache_c.cxx +++ b/src/libserver/symcache/symcache_c.cxx @@ -70,9 +70,7 @@ rspamd_symcache_add_symbol(struct rspamd_symcache *cache, { auto *real_cache = C_API_SYMCACHE(cache); - if (func) { - g_assert (parent == -1); - + if (parent == -1) { return real_cache->add_symbol_with_callback(name, priority, func, user_data, type); } else { diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx index e86a52bf2..b8e2ff2f9 100644 --- a/src/libserver/symcache/symcache_impl.cxx +++ b/src/libserver/symcache/symcache_impl.cxx @@ -610,6 +610,11 @@ auto symcache::add_symbol_with_callback(std::string_view name, real_type_pair.second |= SYMBOL_TYPE_NOSTAT; } + if (real_type_pair.first == symcache_item_type::VIRTUAL) { + msg_err_cache("trying to add virtual symbol %s as real (no parent)", name.data()); + return -1; + } + if ((real_type_pair.second & SYMBOL_TYPE_FINE) && priority == 0) { /* Adjust priority for negative weighted symbols */ priority = 1;