Skip to content

Commit

Permalink
Add object check after parsing json input.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoupey committed Oct 28, 2024
1 parent cb357b3 commit 9caba24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

### Fixed

#### Core solving

- Crash when input is valid JSON but not an object (#1172)

#### Internals

- Iterator type required by `TWRoute::replace` function (#1103)
Expand Down
4 changes: 4 additions & 0 deletions src/utils/input_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ void parse(Input& input, const std::string& input_str, bool geometry) {
}

// Main checks for valid json input.
if (!json_input.IsObject()) {
throw InputException("Input root is not an object.");
}

bool has_jobs = json_input.HasMember("jobs") &&
json_input["jobs"].IsArray() && !json_input["jobs"].Empty();
bool has_shipments = json_input.HasMember("shipments") &&
Expand Down

0 comments on commit 9caba24

Please sign in to comment.