commit f8851d8: [Minor] Another attempt to distinguish normal and virtual symbols
Vsevolod Stakhov
vsevolod at rspamd.com
Sun May 1 12:07:06 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-05-01 13:02:48 +0100
URL: https://github.com/rspamd/rspamd/commit/f8851d834a57f12b2070cbd027cb49dfcf1d320c (HEAD -> master)
[Minor] Another attempt to distinguish normal and virtual symbols
---
src/libserver/symcache/symcache_c.cxx | 4 +---
src/libserver/symcache/symcache_impl.cxx | 5 +++++
2 files changed, 6 insertions(+), 3 deletions(-)
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;
More information about the Commits
mailing list