Skip to content

Commit bf92de2

Browse files
Yi Lifacebook-github-bot
authored andcommitted
Compare full key value when retrieving named data (#14165)
Summary: Compare full input key value when retrieving named data. Previous implementation iterates through the key values, comparing the input key value up to the length of the iterated key value length. This causes wrong data access when there is a key before this value and has partial match in the front part, e.g., "delegate_1" and "delegate_10". Reviewed By: lucylq Differential Revision: D82129824
1 parent 8a0a25b commit bf92de2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

extension/flat_tensor/flat_tensor_data_map.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ Result<const flat_tensor_flatbuffer::NamedData*> get_named_data(
5656
return Error::NotFound;
5757
}
5858
for (int i = 0; i < named_data->size(); i++) {
59-
if (std::strncmp(
59+
if (key.size() == named_data->Get(i)->key()->size() &&
60+
std::strncmp(
6061
named_data->Get(i)->key()->c_str(),
6162
key.data(),
6263
named_data->Get(i)->key()->size()) == 0) {

0 commit comments

Comments
 (0)