浏览代码

Fixes crash when loading *.escn resources with gdnative #20141

The issue is that ResourceFormatLoaderText is a singleton. It was created in a faulty way in
ResourceFormatLoaderNativeScript::load
It was created on the stack, which caused the static singleton pointer to be overwritten. This
causes then segmentation faults if the singleton is used later on.

IMO singleton creation needs to made safer to avoid other similar issues in the future.
Maarten Heremans 6 年之前
父节点
当前提交
cf09952b6b
共有 1 个文件被更改,包括 1 次插入2 次删除
  1. 1 2
      modules/gdnative/nativescript/nativescript.cpp

+ 1 - 2
modules/gdnative/nativescript/nativescript.cpp

@@ -1711,8 +1711,7 @@ void NativeReloadNode::_notification(int p_what) {
 }
 }
 
 
 RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
 RES ResourceFormatLoaderNativeScript::load(const String &p_path, const String &p_original_path, Error *r_error) {
-	ResourceFormatLoaderText rsflt;
-	return rsflt.load(p_path, p_original_path, r_error);
+	return ResourceFormatLoaderText::singleton->load(p_path, p_original_path, r_error);
 }
 }
 
 
 void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const {
 void ResourceFormatLoaderNativeScript::get_recognized_extensions(List<String> *p_extensions) const {