]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Another attempt to distinguish normal and virtual symbols
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 1 May 2022 12:02:48 +0000 (13:02 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sun, 1 May 2022 12:02:48 +0000 (13:02 +0100)
src/libserver/symcache/symcache_c.cxx
src/libserver/symcache/symcache_impl.cxx

index af4d3643255ce82fcd6fef6dcd1bed2245c45afd..7af45ac6485709b800ac9db30b480a49802bf5cc 100644 (file)
@@ -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 {
index e86a52bf2de64309d3f9715a6ede250fb5e21eb3..b8e2ff2f902635e8bc74ec1bfcdaa57b9afb8fb6 100644 (file)
@@ -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;