From 32df4a74308580600486cb07291a10ba9d64f254 Mon Sep 17 00:00:00 2001 From: Elias Bermudez <6505145+debermudez@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:43:38 -0700 Subject: [PATCH] Check that json data is an array or object (#143) Co-authored-by: Elias Bermudez --- src/c++/perf_analyzer/data_loader.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/c++/perf_analyzer/data_loader.cc b/src/c++/perf_analyzer/data_loader.cc index 6288515d5..cf131b076 100644 --- a/src/c++/perf_analyzer/data_loader.cc +++ b/src/c++/perf_analyzer/data_loader.cc @@ -451,6 +451,11 @@ DataLoader::ReadTensorData( const rapidjson::Value* content; + // Check if the input data file is malformed + if (!(tensor.IsArray() || tensor.IsObject())) { + return cb::Error("Input data file is malformed.", pa::GENERIC_ERROR); + } + if (tensor.IsArray()) { content = &tensor; } else if (tensor.HasMember("b64")) {