diff --git a/core/io/resource_uid.cpp b/core/io/resource_uid.cpp index 58b95f86973..9663c1c50d1 100644 --- a/core/io/resource_uid.cpp +++ b/core/io/resource_uid.cpp @@ -328,19 +328,22 @@ Error ResourceUID::update_cache() { } String ResourceUID::get_path_from_cache(Ref &p_cache_file, const String &p_uid_string) { - const uint32_t entry_count = p_cache_file->get_32(); - CharString cs; - for (uint32_t i = 0; i < entry_count; i++) { - int64_t id = p_cache_file->get_64(); - int32_t len = p_cache_file->get_32(); - cs.resize_uninitialized(len + 1); - ERR_FAIL_COND_V(cs.size() != len + 1, String()); - cs[len] = 0; - int32_t rl = p_cache_file->get_buffer((uint8_t *)cs.ptrw(), len); - ERR_FAIL_COND_V(rl != len, String()); + const int64_t uid_from_string = singleton->text_to_id(p_uid_string); + if (uid_from_string != INVALID_ID) { + const uint32_t entry_count = p_cache_file->get_32(); + CharString cs; + for (uint32_t i = 0; i < entry_count; i++) { + int64_t id = p_cache_file->get_64(); + int32_t len = p_cache_file->get_32(); + cs.resize_uninitialized(len + 1); + ERR_FAIL_COND_V(cs.size() != len + 1, String()); + cs[len] = 0; + int32_t rl = p_cache_file->get_buffer((uint8_t *)cs.ptrw(), len); + ERR_FAIL_COND_V(rl != len, String()); - if (singleton->id_to_text(id) == p_uid_string) { - return String::utf8(cs.get_data()); + if (id == uid_from_string) { + return String::utf8(cs.get_data()); + } } } return String();