Skip to content

Commit e4c91d4

Browse files
authored
fix: Proper handling of shape tensor size (#110)
1 parent 9d7ba1d commit e4c91d4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/shape_tensor.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright 2024-2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Redistribution and use in source and binary forms, with or without
44
// modification, are permitted provided that the following conditions
@@ -72,6 +72,11 @@ ShapeTensor::SetDataFromBuffer(
7272
*reinterpret_cast<int64_t*>(data_.get()) =
7373
static_cast<int64_t>(total_batch_size);
7474
}
75+
if (size_ < datatype_size) {
76+
return TRITONSERVER_ErrorNew(
77+
TRITONSERVER_ERROR_INVALID_ARG,
78+
"Unexpected integer underflow while calculating shape tensor size.");
79+
}
7580
std::memcpy(
7681
data_.get() + datatype_size, data_buffer, size_ - datatype_size);
7782
} else {

0 commit comments

Comments
 (0)