File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -38,13 +38,17 @@ void bson_free_deleter(std::uint8_t* ptr) {
38
38
39
39
std::string to_json_helper (document::view view, decltype (bson_as_json) converter) {
40
40
bson_t bson;
41
- bson_init_static (&bson, view.data (), view.length ());
41
+
42
+ if (!bson_init_static (&bson, view.data (), view.length ())) {
43
+ throw exception (error_code::k_failed_converting_bson_to_json);
44
+ }
42
45
43
46
size_t size;
44
47
auto result = converter (&bson, &size);
45
48
46
- if (!result)
49
+ if (!result) {
47
50
throw exception (error_code::k_failed_converting_bson_to_json);
51
+ }
48
52
49
53
const auto deleter = [](char * result) { bson_free (result); };
50
54
const std::unique_ptr<char [], decltype (deleter)> cleanup (result, deleter);
You can’t perform that action at this time.
0 commit comments