Skip to content

Commit ca4b4be

Browse files
committed
crate: error on reading duplicate key in crate map
...if PXR_PREFER_SAFETY_OVER_SPEED is set
1 parent 0c7c52b commit ca4b4be

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pxr/usd/sdf/crateFile.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,13 @@ class CrateFile::_Reader
11451145
// separate because the two modifications to 'src' must be correctly
11461146
// sequenced.
11471147
auto key = Read<typename Map::key_type>();
1148+
if constexpr (SafetyOverSpeed) {
1149+
if map.find(key) != map.end() {
1150+
TF_RUNTIME_ERROR("Corrupt asset <%s>: Duplicate map key %s",
1151+
crate->GetAssetPath().c_str(),
1152+
key.GetText().c_str());
1153+
}
1154+
}
11481155
map[key] = Read<typename Map::mapped_type>();
11491156
}
11501157
return map;

0 commit comments

Comments
 (0)