Merge pull request #74590 from timothyqiu/the-forbidden-directory

Fix crash when dumping extension API in a non-writable directory
This commit is contained in:
Rémi Verschelde 2023-03-08 08:59:27 +01:00
commit 8b1568af70
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 2 additions and 0 deletions

View file

@ -1052,6 +1052,7 @@ void GDExtensionAPIDump::generate_extension_json_file(const String &p_path) {
String text = json->stringify(api, "\t", false) + "\n"; String text = json->stringify(api, "\t", false) + "\n";
Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE); Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_MSG(fa.is_null(), vformat("Cannot open file '%s' for writing.", p_path));
fa->store_string(text); fa->store_string(text);
} }

View file

@ -27,6 +27,7 @@ class GDExtensionInterfaceDump {
public: public:
static void generate_gdextension_interface_file(const String &p_path) { static void generate_gdextension_interface_file(const String &p_path) {
Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE); Ref<FileAccess> fa = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_MSG(fa.is_null(), vformat("Cannot open file '%s' for writing.", p_path));
CharString cs(gdextension_interface_dump); CharString cs(gdextension_interface_dump);
fa->store_buffer((const uint8_t *)cs.ptr(), cs.length()); fa->store_buffer((const uint8_t *)cs.ptr(), cs.length());
}; };