File tree 1 file changed +8
-7
lines changed
src/bsoncxx/lib/bsoncxx/v_noabi/bsoncxx/builder
1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -298,13 +298,14 @@ core& core::append(types::b_double const& value) {
298
298
299
299
core& core::append (types::b_string const & value) {
300
300
stdx::string_view key = _impl->next_key ();
301
-
302
- if (!bson_append_utf8 (
303
- _impl->back (),
304
- key.data (),
305
- static_cast <std::int32_t >(key.length ()),
306
- value.value .data (),
307
- static_cast <std::int32_t >(value.value .length ()))) {
301
+ std::size_t value_length = value.value .length ();
302
+
303
+ if (value_length > std::size_t {INT32_MAX} || !bson_append_utf8 (
304
+ _impl->back (),
305
+ key.data (),
306
+ static_cast <std::int32_t >(key.length ()),
307
+ value.value .data (),
308
+ static_cast <std::int32_t >(value_length))) {
308
309
throw bsoncxx::v_noabi::exception {error_code::k_cannot_append_string};
309
310
}
310
311
You can’t perform that action at this time.
0 commit comments