@@ -1555,8 +1555,11 @@ bson_append_regex (bson_t *bson,
1555
1555
1556
1556
1557
1557
bool
1558
- bson_append_regex_w_len (bson_t * bson , const char * key , int key_length ,
1559
- const char * regex , int regex_length ,
1558
+ bson_append_regex_w_len (bson_t * bson ,
1559
+ const char * key ,
1560
+ int key_length ,
1561
+ const char * regex ,
1562
+ int regex_length ,
1560
1563
const char * options )
1561
1564
{
1562
1565
static const uint8_t type = BSON_TYPE_REGEX ;
@@ -1586,21 +1589,22 @@ bson_append_regex_w_len (bson_t *bson, const char *key, int key_length,
1586
1589
1587
1590
_bson_append_regex_options_sorted (options_sorted , options );
1588
1591
1589
- r = _bson_append (bson ,
1590
- 6 ,
1591
- (1 + key_length + 1 + regex_length + 1 + options_sorted -> len + 1 ),
1592
- 1 ,
1593
- & type ,
1594
- key_length ,
1595
- key ,
1596
- 1 ,
1597
- & gZero ,
1598
- regex_length ,
1599
- regex ,
1600
- 1 ,
1601
- & gZero ,
1602
- options_sorted -> len + 1 ,
1603
- options_sorted -> str );
1592
+ r = _bson_append (
1593
+ bson ,
1594
+ 6 ,
1595
+ (1 + key_length + 1 + regex_length + 1 + options_sorted -> len + 1 ),
1596
+ 1 ,
1597
+ & type ,
1598
+ key_length ,
1599
+ key ,
1600
+ 1 ,
1601
+ & gZero ,
1602
+ regex_length ,
1603
+ regex ,
1604
+ 1 ,
1605
+ & gZero ,
1606
+ options_sorted -> len + 1 ,
1607
+ options_sorted -> str );
1604
1608
1605
1609
bson_string_free (options_sorted , true);
1606
1610
@@ -2191,7 +2195,7 @@ bson_copy_to (const bson_t *src, bson_t *dst)
2191
2195
if ((src -> flags & BSON_FLAG_INLINE )) {
2192
2196
#ifdef BSON_MEMCHECK
2193
2197
dst -> len = src -> len ;
2194
- dst -> canary = malloc (1 );
2198
+ dst -> canary = malloc (1 );
2195
2199
memcpy (dst -> padding , src -> padding , sizeof dst -> padding );
2196
2200
#else
2197
2201
memcpy (dst , src , sizeof * dst );
@@ -2963,10 +2967,10 @@ _bson_as_json_visit_code (const bson_iter_t *iter,
2963
2967
2964
2968
static bool
2965
2969
_bson_as_json_visit_symbol (const bson_iter_t * iter ,
2966
- const char * key ,
2967
- size_t v_symbol_len ,
2968
- const char * v_symbol ,
2969
- void * data )
2970
+ const char * key ,
2971
+ size_t v_symbol_len ,
2972
+ const char * v_symbol ,
2973
+ void * data )
2970
2974
{
2971
2975
bson_json_state_t * state = data ;
2972
2976
char * escaped ;
@@ -3032,30 +3036,18 @@ _bson_as_json_visit_codewscope (const bson_iter_t *iter,
3032
3036
3033
3037
3034
3038
static const bson_visitor_t bson_as_json_visitors = {
3035
- _bson_as_json_visit_before ,
3036
- NULL , /* visit_after */
3037
- _bson_as_json_visit_corrupt ,
3038
- _bson_as_json_visit_double ,
3039
- _bson_as_json_visit_utf8 ,
3040
- _bson_as_json_visit_document ,
3041
- _bson_as_json_visit_array ,
3042
- _bson_as_json_visit_binary ,
3043
- _bson_as_json_visit_undefined ,
3044
- _bson_as_json_visit_oid ,
3045
- _bson_as_json_visit_bool ,
3046
- _bson_as_json_visit_date_time ,
3047
- _bson_as_json_visit_null ,
3048
- _bson_as_json_visit_regex ,
3049
- _bson_as_json_visit_dbpointer ,
3050
- _bson_as_json_visit_code ,
3051
- _bson_as_json_visit_symbol ,
3052
- _bson_as_json_visit_codewscope ,
3053
- _bson_as_json_visit_int32 ,
3054
- _bson_as_json_visit_timestamp ,
3055
- _bson_as_json_visit_int64 ,
3056
- _bson_as_json_visit_maxkey ,
3057
- _bson_as_json_visit_minkey ,
3058
- NULL , /* visit_unsupported_type */
3039
+ _bson_as_json_visit_before , NULL , /* visit_after */
3040
+ _bson_as_json_visit_corrupt , _bson_as_json_visit_double ,
3041
+ _bson_as_json_visit_utf8 , _bson_as_json_visit_document ,
3042
+ _bson_as_json_visit_array , _bson_as_json_visit_binary ,
3043
+ _bson_as_json_visit_undefined , _bson_as_json_visit_oid ,
3044
+ _bson_as_json_visit_bool , _bson_as_json_visit_date_time ,
3045
+ _bson_as_json_visit_null , _bson_as_json_visit_regex ,
3046
+ _bson_as_json_visit_dbpointer , _bson_as_json_visit_code ,
3047
+ _bson_as_json_visit_symbol , _bson_as_json_visit_codewscope ,
3048
+ _bson_as_json_visit_int32 , _bson_as_json_visit_timestamp ,
3049
+ _bson_as_json_visit_int64 , _bson_as_json_visit_maxkey ,
3050
+ _bson_as_json_visit_minkey , NULL , /* visit_unsupported_type */
3059
3051
_bson_as_json_visit_decimal128 ,
3060
3052
};
3061
3053
@@ -3080,6 +3072,7 @@ _bson_as_json_visit_document (const bson_iter_t *iter,
3080
3072
child_state .depth = state -> depth + 1 ;
3081
3073
child_state .mode = state -> mode ;
3082
3074
if (bson_iter_visit_all (& child , & bson_as_json_visitors , & child_state )) {
3075
+ bson_string_free (child_state .str , true);
3083
3076
return true;
3084
3077
}
3085
3078
@@ -3112,6 +3105,7 @@ _bson_as_json_visit_array (const bson_iter_t *iter,
3112
3105
child_state .depth = state -> depth + 1 ;
3113
3106
child_state .mode = state -> mode ;
3114
3107
if (bson_iter_visit_all (& child , & bson_as_json_visitors , & child_state )) {
3108
+ bson_string_free (child_state .str , true);
3115
3109
return true;
3116
3110
}
3117
3111
0 commit comments