commit c55b683: [Minor] Fix ownership issue
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Oct 6 10:07:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-10-06 10:39:20 +0100
URL: https://github.com/rspamd/rspamd/commit/c55b683b92b311c9384f960b3a976bb288facac9
[Minor] Fix ownership issue
---
src/libmime/received.cxx | 12 +++---------
src/libmime/received.hxx | 8 ++++----
2 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/libmime/received.cxx b/src/libmime/received.cxx
index 3dd972f91..550823a4d 100644
--- a/src/libmime/received.cxx
+++ b/src/libmime/received.cxx
@@ -629,15 +629,9 @@ received_header_parse(received_header_chain &chain, rspamd_mempool_t *pool,
}
break;
case received_part_type::RSPAMD_RECEIVED_PART_FOR:
- rh.for_addr = rspamd_email_address_from_smtp(part.data.data(),
- part.data.size());
-
- if (rh.for_addr) {
- if (rh.for_addr->addr_len > 0) {
- rh.for_mbox = std::string_view{rh.for_addr->addr,
- rh.for_addr->addr_len};
- }
- }
+ rh.for_mbox.assign_copy(part.data);
+ rh.for_addr = rspamd_email_address_from_smtp(rh.for_mbox.data(),
+ rh.for_mbox.size());
break;
default:
/* Do nothing */
diff --git a/src/libmime/received.hxx b/src/libmime/received.hxx
index 20164329f..98d46770b 100644
--- a/src/libmime/received.hxx
+++ b/src/libmime/received.hxx
@@ -103,7 +103,7 @@ struct received_header {
mime_string real_hostname;
mime_string real_ip;
mime_string by_hostname;
- std::string_view for_mbox;
+ mime_string for_mbox;
struct rspamd_email_address *for_addr = nullptr;
rspamd_inet_addr_t *addr = nullptr;
struct rspamd_mime_header *hdr = nullptr;
@@ -128,7 +128,7 @@ struct received_header {
real_hostname = std::move(other.real_hostname);
real_ip = std::move(other.real_ip);
by_hostname = std::move(other.by_hostname);
- for_mbox = other.for_mbox;
+ for_mbox = std::move(other.for_mbox);
timestamp = other.timestamp;
flags = other.flags;
std::swap(for_addr, other.for_addr);
@@ -159,7 +159,7 @@ struct received_header {
rh.from_ip = map.at("from_ip"sv);
}
if (map.contains("for_mbox")) {
- rh.for_mbox = map.at("for_mbox"sv);
+ rh.for_mbox.assign_copy(map.at("for_mbox"sv));
}
return rh;
@@ -185,7 +185,7 @@ struct received_header {
map["from_ip"] = from_ip;
}
if (!for_mbox.empty()) {
- map["for_mbox"] = for_mbox;
+ map["for_mbox"] = for_mbox.as_view();
}
return map;
More information about the Commits
mailing list