Skip to content

Commit c2cd1d5

Browse files
committed
libpressio verison 0.66.3
Bug Fixes: + fixed several cases where JSON parsing errors could cause an uncaught exception in C
1 parent 9cbe040 commit c2cd1d5

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
2-
project(libpressio VERSION "0.66.2" LANGUAGES CXX C)
2+
project(libpressio VERSION "0.66.3" LANGUAGES CXX C)
33

44
#correct was to set a default build type
55
# https://blog.kitware.com/cmake-and-the-default-build-type/

COPYRIGHT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Copyright © 2021 , UChicago Argonne, LLC
22
All Rights Reserved
3-
[libpressio, Version 0.65.0]
3+
[libpressio, Version 0.66.3]
44
Robert Underwood
55
Argonne National Laboratory
66

src/pressio_options_json.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <pressio_options.h>
55
#include <vector>
66
#include <stdexcept>
7+
#include <sstream>
78

89
void to_json(nlohmann::json& j, pressio_data const& data){
910
j["dims"] = data.dimensions();
@@ -256,10 +257,20 @@ void from_json(nlohmann::json const& j, pressio_options& options) {
256257

257258
extern "C" {
258259
struct pressio_options* pressio_options_new_json(struct pressio* library, const char* json) {
259-
nlohmann::json parsed = nlohmann::json::parse(json);
260260
pressio_options* options = nullptr;
261261
try {
262+
nlohmann::json parsed = nlohmann::json::parse(json);
262263
options = new pressio_options(parsed.get<pressio_options>());
264+
} catch (nlohmann::detail::out_of_range& ex) {
265+
if(library) {
266+
library->set_error(2, ex.what());
267+
}
268+
} catch (nlohmann::detail::parse_error& ex) {
269+
if(library) {
270+
std::stringstream err_msg;
271+
err_msg << ex.what() << "\n" << json;
272+
library->set_error(2, err_msg.str());
273+
}
263274
} catch (std::runtime_error& ex) {
264275
if(library) {
265276
library->set_error(1, ex.what());

0 commit comments

Comments
 (0)