Skip to content
Merged
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
32 changes: 26 additions & 6 deletions backends/arm/runtime/VGFBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* LICENSE file in the root directory of this source tree.
*/

#include <list>
#include <numeric>
#include <cinttypes>
using namespace std;

#include <c10/util/safe_numerics.h>
Comment on lines +8 to +11
#include <executorch/runtime/backend/interface.h>
#include <executorch/runtime/core/error.h>
#include <executorch/runtime/core/evalue.h>
Expand Down Expand Up @@ -191,8 +191,18 @@ class VGFBackend final : public ::executorch::runtime::BackendInterface {
if (!io->is_input)
continue;

size_t io_size = accumulate(
io->size.begin(), io->size.end(), io->elt_size, std::multiplies<>());
size_t io_size = io->elt_size;
for (int64_t dim : io->size) {
ET_CHECK_OR_RETURN_ERROR(
dim >= 0,
InvalidArgument,
"Negative dimension in IO size: %" PRId64,
dim);
ET_CHECK_OR_RETURN_ERROR(
!c10::mul_overflows(io_size, static_cast<size_t>(dim), &io_size),
InvalidArgument,
"Overflow computing IO buffer size");
}
Comment on lines +194 to +205

void* data;
if (!repr->map_io(io, &data)) {
Expand Down Expand Up @@ -226,8 +236,18 @@ class VGFBackend final : public ::executorch::runtime::BackendInterface {
if (io->is_input)
continue;

size_t io_size = accumulate(
io->size.begin(), io->size.end(), io->elt_size, std::multiplies<>());
size_t io_size = io->elt_size;
for (int64_t dim : io->size) {
ET_CHECK_OR_RETURN_ERROR(
dim >= 0,
InvalidArgument,
"Negative dimension in IO size: %" PRId64,
dim);
ET_CHECK_OR_RETURN_ERROR(
!c10::mul_overflows(io_size, static_cast<size_t>(dim), &io_size),
InvalidArgument,
"Overflow computing IO buffer size");
}

void* data;
if (!repr->map_io(io, &data)) {
Expand Down
Loading