Skip to content

Update cache_entry.cc to fix data type mismatches and out of bound er… #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cache_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ CacheEntry::SerializeResponse(InferenceResponse* response, Buffer& buffer)
position += sizeof(uint32_t);

for (const auto& output : response->Outputs()) {
uint64_t packed_output_byte_size = 0;
size_t packed_output_byte_size = 0;
RETURN_IF_ERROR(SerializeResponseOutput(
output, base + position, &packed_output_byte_size));
// 2. Then the packed buffer will hold pairs of (output_size, output_bytes)
Expand Down Expand Up @@ -255,7 +255,7 @@ CacheEntry::SerializeResponseOutput(
// Pack everything into provided buffer
uint64_t position = 0;
// Total serialized output size
memcpy(buffer + position, &total_byte_size, sizeof(uint64_t));
memcpy(buffer + position, &total_byte_size, sizeof(size_t));
position += sizeof(uint64_t);

// Name
Expand Down Expand Up @@ -327,7 +327,7 @@ CacheEntry::DeserializeBuffer(InferenceResponse* response, const Buffer& buffer)

for (size_t i = 0; i < num_outputs; i++) {
// Get size of packed output
uint64_t packed_output_size = 0;
size_t packed_output_size = 0;
std::memcpy(
&packed_output_size, base + position, sizeof(packed_output_size));
position += sizeof(packed_output_size);
Expand Down