Fix crash for TypeScript enum in substruct (#8430)

See https://github.com/google/flatbuffers/issues/8299.
This commit is contained in:
Fergus Henderson 2025-01-08 14:38:34 +13:00 committed by GitHub
parent 8694806f14
commit 99fda81905
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -901,11 +901,15 @@ class TsGenerator : public BaseGenerator {
std::string bare_file_path;
std::string rel_file_path;
const auto &dep_comps = dependent.defined_namespace->components;
for (size_t i = 0; i < dep_comps.size(); i++) {
rel_file_path += i == 0 ? ".." : (kPathSeparator + std::string(".."));
if (dependent.defined_namespace) {
const auto &dep_comps = dependent.defined_namespace->components;
for (size_t i = 0; i < dep_comps.size(); i++) {
rel_file_path += i == 0 ? ".." : (kPathSeparator + std::string(".."));
}
if (dep_comps.size() == 0) { rel_file_path += "."; }
} else {
rel_file_path += "..";
}
if (dep_comps.size() == 0) { rel_file_path += "."; }
bare_file_path +=
kPathSeparator +