From 496afd66ea05e08d2a54f9bf38e24f822cc31485 Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Thu, 14 Dec 2023 19:27:47 -0600 Subject: [PATCH] [ox/fs] Fix segfault in FileAddress --- deps/ox/src/ox/fs/filesystem/filelocation.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/deps/ox/src/ox/fs/filesystem/filelocation.cpp b/deps/ox/src/ox/fs/filesystem/filelocation.cpp index d0ac5924..3dfb9f3e 100644 --- a/deps/ox/src/ox/fs/filesystem/filelocation.cpp +++ b/deps/ox/src/ox/fs/filesystem/filelocation.cpp @@ -45,9 +45,14 @@ FileAddress &FileAddress::operator=(const FileAddress &other) noexcept { switch (m_type) { case FileAddressType::Path: { - auto strSize = ox_strlen(other.m_data.path) + 1; - m_data.path = new char[strSize]; - ox_memcpy(m_data.path, other.m_data.path, strSize); + if (other.m_data.path) { + auto strSize = ox_strlen(other.m_data.path) + 1; + m_data.path = new char[strSize]; + ox_memcpy(m_data.path, other.m_data.path, strSize); + } else { + m_data.constPath = ""; + m_type = FileAddressType::ConstPath; + } break; } case FileAddressType::ConstPath: