summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-30 09:58:35 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-09-30 09:58:35 +0200
commitc7a75d9c92fad732556160cdc9f486dd1a2e8cac (patch)
treeba6c25f6763619eacd3e82adc26449e8591ad0b4
parent4c73e8ba1a4c0533056c04e709611a67c0edf16a (diff)
parentd873c549a2aa23b5a05e3085f25cbcbb2bef2cfd (diff)
Merge pull request #66634 from timothyqiu/resource-uid
Fix crash when executing `ResourceUID.set_id`
-rw-r--r--core/io/resource_uid.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp
index 5324c5dd84..ed5ce3b911 100644
--- a/core/io/resource_uid.cpp
+++ b/core/io/resource_uid.cpp
@@ -113,7 +113,12 @@ void ResourceUID::set_id(ID p_id, const String &p_path) {
MutexLock l(mutex);
ERR_FAIL_COND(!unique_ids.has(p_id));
CharString cs = p_path.utf8();
- if (strcmp(cs.ptr(), unique_ids[p_id].cs.ptr()) != 0) {
+ const char *update_ptr = cs.ptr();
+ const char *cached_ptr = unique_ids[p_id].cs.ptr();
+ if (update_ptr == nullptr && cached_ptr == nullptr) {
+ return; // Both are empty strings.
+ }
+ if ((update_ptr == nullptr) != (cached_ptr == nullptr) || strcmp(update_ptr, cached_ptr) != 0) {
unique_ids[p_id].cs = cs;
unique_ids[p_id].saved_to_cache = false; //changed
changed = true;