[ox] Fix TypeDescWriter segfault

This commit is contained in:
Gary Talent 2023-12-29 18:42:59 -06:00
parent a0c8146396
commit 72dddcaee5
2 changed files with 6 additions and 2 deletions

View File

@ -219,9 +219,11 @@ template<typename T>
constexpr Error TypeDescWriter::field(CRStringView name, const T *val) noexcept { constexpr Error TypeDescWriter::field(CRStringView name, const T *val) noexcept {
if (m_type) { if (m_type) {
if constexpr(isVector_v<T> || isArray_v<T>) { if constexpr(isVector_v<T> || isArray_v<T>) {
return field(name, val->data(), 0, detail::buildSubscriptStack(val)); typename T::value_type *data = nullptr;
return field(name, data, 0, detail::buildSubscriptStack(val));
} else if constexpr(isSmartPtr_v<T>) { } else if constexpr(isSmartPtr_v<T>) {
return field(name, val->get(), 0, detail::buildSubscriptStack(val)); typename T::value_type *data = nullptr;
return field(name, data, 0, detail::buildSubscriptStack(val));
} else if constexpr(is_pointer_v<T>) { } else if constexpr(is_pointer_v<T>) {
return field(name, val, 0, detail::buildSubscriptStack(val)); return field(name, val, 0, detail::buildSubscriptStack(val));
} else { } else {

View File

@ -74,6 +74,7 @@ class SharedPtr {
int *m_refCnt = nullptr; int *m_refCnt = nullptr;
public: public:
using value_type = T;
explicit constexpr SharedPtr(T *t = nullptr) noexcept: m_t(t), m_refCnt(new int) { explicit constexpr SharedPtr(T *t = nullptr) noexcept: m_t(t), m_refCnt(new int) {
} }
@ -183,6 +184,7 @@ class UniquePtr {
T *m_t = nullptr; T *m_t = nullptr;
public: public:
using value_type = T;
explicit constexpr UniquePtr(T *t = nullptr) noexcept: m_t(t) { explicit constexpr UniquePtr(T *t = nullptr) noexcept: m_t(t) {
} }