You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
StringName: fix returning dangling data from char constructor.
Fixes a copy paste mistake in the `StringName(const char *,bool)` constructor, to match the same form as the other two constrcutors. This fixes a case where this constructor can return a dangling pointer and cause use-after-free.
This commit is contained in:
@@ -226,8 +226,7 @@ StringName::StringName(const char *p_name, bool p_static) {
|
|||||||
_data = _data->next;
|
_data = _data->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data) {
|
if (_data && _data->refcount.ref()) {
|
||||||
if (_data->refcount.ref()) {
|
|
||||||
// exists
|
// exists
|
||||||
if (p_static) {
|
if (p_static) {
|
||||||
_data->static_count.increment();
|
_data->static_count.increment();
|
||||||
@@ -237,8 +236,6 @@ StringName::StringName(const char *p_name, bool p_static) {
|
|||||||
_data->debug_references++;
|
_data->debug_references++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,8 +285,7 @@ StringName::StringName(const StaticCString &p_static_string, bool p_static) {
|
|||||||
_data = _data->next;
|
_data = _data->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data) {
|
if (_data && _data->refcount.ref()) {
|
||||||
if (_data->refcount.ref()) {
|
|
||||||
// exists
|
// exists
|
||||||
if (p_static) {
|
if (p_static) {
|
||||||
_data->static_count.increment();
|
_data->static_count.increment();
|
||||||
@@ -301,7 +297,6 @@ StringName::StringName(const StaticCString &p_static_string, bool p_static) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_data = memnew(_Data);
|
_data = memnew(_Data);
|
||||||
|
|
||||||
@@ -348,8 +343,7 @@ StringName::StringName(const String &p_name, bool p_static) {
|
|||||||
_data = _data->next;
|
_data = _data->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_data) {
|
if (_data && _data->refcount.ref()) {
|
||||||
if (_data->refcount.ref()) {
|
|
||||||
// exists
|
// exists
|
||||||
if (p_static) {
|
if (p_static) {
|
||||||
_data->static_count.increment();
|
_data->static_count.increment();
|
||||||
@@ -361,7 +355,6 @@ StringName::StringName(const String &p_name, bool p_static) {
|
|||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_data = memnew(_Data);
|
_data = memnew(_Data);
|
||||||
_data->name = p_name;
|
_data->name = p_name;
|
||||||
|
|||||||
Reference in New Issue
Block a user