File tree 2 files changed +12
-8
lines changed
x/mongo/driver/mongocrypt 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -379,9 +379,6 @@ func TestClientSideEncryptionProse(t *testing.T) {
379
379
}
380
380
})
381
381
mt .Run ("4. bson size limits" , func (mt * mtest.T ) {
382
- // TODO(GODRIVER-2872): Fix and unskip this test case.
383
- mt .Skip ("Test fails frequently, skipping. See GODRIVER-2872" )
384
-
385
382
kmsProviders := map [string ]map [string ]interface {}{
386
383
"local" : {
387
384
"key" : localMasterKey ,
Original file line number Diff line number Diff line change 9
9
10
10
package mongocrypt
11
11
12
- // #include <mongocrypt.h>
12
+ /*
13
+ #include <stdlib.h>
14
+ #include <mongocrypt.h>
15
+ */
13
16
import "C"
14
17
import (
15
18
"unsafe"
16
19
)
17
20
18
21
// binary is a wrapper type around a mongocrypt_binary_t*
19
22
type binary struct {
23
+ p * C.uint8_t
20
24
wrapped * C.mongocrypt_binary_t
21
25
}
22
26
@@ -33,11 +37,11 @@ func newBinaryFromBytes(data []byte) *binary {
33
37
return newBinary ()
34
38
}
35
39
36
- // We don't need C.CBytes here because data cannot go out of scope. Any mongocrypt function that takes a
37
- // mongocrypt_binary_t will make a copy of the data so the data can be garbage collected after calling.
38
- addr := (* C .uint8_t )(unsafe .Pointer (& data [0 ])) // uint8_t*
39
- dataLen := C .uint32_t (len (data )) // uint32_t
40
+ // TODO: Consider using runtime.Pinner to replace the C.CBytes after using go1.21.0.
41
+ addr := (* C .uint8_t )(C .CBytes (data )) // uint8_t*
42
+ dataLen := C .uint32_t (len (data )) // uint32_t
40
43
return & binary {
44
+ p : addr ,
41
45
wrapped : C .mongocrypt_binary_new_from_data (addr , dataLen ),
42
46
}
43
47
}
@@ -52,5 +56,8 @@ func (b *binary) toBytes() []byte {
52
56
53
57
// close cleans up any resources associated with the given binary instance.
54
58
func (b * binary ) close () {
59
+ if b .p != nil {
60
+ C .free (unsafe .Pointer (b .p ))
61
+ }
55
62
C .mongocrypt_binary_destroy (b .wrapped )
56
63
}
You can’t perform that action at this time.
0 commit comments