Skip to content

Commit

Permalink
matdbg: fix two memory bugs (#8337)
Browse files Browse the repository at this point in the history
- murmur3 expects word size not byte size
 - should use uint8_t in addressing blob source.

both would crash when asan is enabled.
  • Loading branch information
poweifeng authored Jan 6, 2025
1 parent 8c1e028 commit 7d0b652
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libs/matdbg/src/DebugServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ DebugServer::addMaterial(const CString& name, const void* data, size_t size, voi
// material data.
constexpr uint32_t seed = 42;
uint64_t dataSpace[2] = {(uint64_t) data, (uint64_t) userdata};
uint32_t const key = utils::hash::murmur3((const uint32_t*) dataSpace, sizeof(dataSpace), seed);
uint32_t const key = utils::hash::murmurSlow((uint8_t const*) dataSpace, sizeof(dataSpace), seed);

// Retain a copy of the package to permit queries after the client application has
// freed up the original material package.
Expand Down
2 changes: 1 addition & 1 deletion libs/matdbg/src/ShaderReplacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ void BlobIndex::writeChunks(ostream& stream) {
for (auto& record : mShaderRecords) {
const auto& src = mDataBlobs[record.dictionaryIndex];
assert(src.size() % 4 == 0);
const uint32_t* ptr = (const uint32_t*) src.data();
uint8_t const* ptr = (uint8_t const*) src.data();
record.dictionaryIndex = blobs.addBlob(vector<uint8_t>(ptr, ptr + src.size()));
}

Expand Down

0 comments on commit 7d0b652

Please sign in to comment.