summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-10-19 17:11:42 +0200
committerYuri Sizov <yuris@humnom.net>2023-10-19 17:13:15 +0200
commit4952d37f4bfaaed43644f56c6798f4c43e70bf68 (patch)
treed48e0fa3374f2c514c05289407187bf64a6b6f67
parentf8818f85e6c43cdf1277e8ae85eba19ca0a003b0 (diff)
downloadredot-engine-4952d37f4bfaaed43644f56c6798f4c43e70bf68.tar.gz
Fix StringName leaks in VariantParser
-rw-r--r--core/string/string_name.cpp10
-rw-r--r--core/variant/variant_parser.cpp2
-rw-r--r--modules/webrtc/webrtc_peer_connection.cpp4
3 files changed, 7 insertions, 9 deletions
diff --git a/core/string/string_name.cpp b/core/string/string_name.cpp
index 4402e44ad4..5a8df07410 100644
--- a/core/string/string_name.cpp
+++ b/core/string/string_name.cpp
@@ -100,11 +100,9 @@ void StringName::cleanup() {
lost_strings++;
if (OS::get_singleton()->is_stdout_verbose()) {
- if (d->cname) {
- print_line("Orphan StringName: " + String(d->cname));
- } else {
- print_line("Orphan StringName: " + String(d->name));
- }
+ String dname = String(d->cname ? d->cname : d->name);
+
+ print_line(vformat("Orphan StringName: %s (static: %d, total: %d)", dname, d->static_count.get(), d->refcount.get()));
}
}
@@ -113,7 +111,7 @@ void StringName::cleanup() {
}
}
if (lost_strings) {
- print_verbose("StringName: " + itos(lost_strings) + " unclaimed string names at exit.");
+ print_verbose(vformat("StringName: %d unclaimed string names at exit.", lost_strings));
}
configured = false;
}
diff --git a/core/variant/variant_parser.cpp b/core/variant/variant_parser.cpp
index fea1622222..86e7654090 100644
--- a/core/variant/variant_parser.cpp
+++ b/core/variant/variant_parser.cpp
@@ -1075,7 +1075,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
return ERR_PARSE_ERROR;
}
- static HashMap<StringName, Variant::Type> builtin_types;
+ static HashMap<String, Variant::Type> builtin_types;
if (builtin_types.is_empty()) {
for (int i = 1; i < Variant::VARIANT_MAX; i++) {
builtin_types[Variant::get_type_name((Variant::Type)i)] = (Variant::Type)i;
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp
index 8bad6fd784..0a50b677c4 100644
--- a/modules/webrtc/webrtc_peer_connection.cpp
+++ b/modules/webrtc/webrtc_peer_connection.cpp
@@ -40,14 +40,14 @@ StringName WebRTCPeerConnection::default_extension;
void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) {
ERR_FAIL_COND_MSG(!ClassDB::is_parent_class(p_extension, WebRTCPeerConnectionExtension::get_class_static()), vformat("Can't make %s the default WebRTC extension since it does not extend WebRTCPeerConnectionExtension.", p_extension));
- default_extension = p_extension;
+ default_extension = StringName(p_extension, true);
}
WebRTCPeerConnection *WebRTCPeerConnection::create() {
#ifdef WEB_ENABLED
return memnew(WebRTCPeerConnectionJS);
#else
- if (default_extension == String()) {
+ if (default_extension == StringName()) {
WARN_PRINT_ONCE("No default WebRTC extension configured.");
return memnew(WebRTCPeerConnectionExtension);
}