fix CCArrayExt crashing on a nullptr array

This commit is contained in:
HJfod 2022-10-26 16:20:39 +03:00
parent 9e4b236d1b
commit 2a81ed1ac1
2 changed files with 10 additions and 5 deletions
CMakeLists.txt
loader/include/Geode/utils

View file

@ -106,7 +106,7 @@ elseif(EXISTS ${GEODE_PLATFORM_BIN_PATH})
)
else()
message(FATAL_ERROR
"No valid loader binary to link to! Install prebuilts with `geode sdk install-prebuilts` "
"or build Geode from source."
"No valid loader binary to link to! Install prebuilts with `geode sdk install-prebuilts`, "
"or build Geode from source and add `set(GEODE_LINK_NIGHTLY On)` to your CMakeLists.txt."
)
endif()

View file

@ -317,15 +317,20 @@ namespace geode::cocos {
~CCArrayExt() {}
auto begin() {
if (!m_arr) {
return CCArrayIterator<T*>(nullptr);
}
return CCArrayIterator<T*>(reinterpret_cast<T**>(m_arr->data->arr));
}
auto end() {
if (!m_arr) {
return CCArrayIterator<T*>(nullptr);
}
return CCArrayIterator<T*>(reinterpret_cast<T**>(m_arr->data->arr) + m_arr->count());
}
auto size() const {
return m_arr->count();
size_t size() const {
return m_arr ? m_arr->count() : 0;
}
T operator[](size_t index) {