Skip to content

Commit 66601dd

Browse files
committed
More BCE.
1 parent 58b66b7 commit 66601dd

File tree

5 files changed

+16
-7
lines changed

5 files changed

+16
-7
lines changed

ext/blobio/blob.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ func Register(db *sqlite3.Conn) error {
4444
type OpenCallback func(*sqlite3.Blob, ...sqlite3.Value) error
4545

4646
func readblob(ctx sqlite3.Context, arg ...sqlite3.Value) {
47+
_ = arg[5] // bounds check
48+
4749
blob, err := getAuxBlob(ctx, arg, false)
4850
if err != nil {
4951
ctx.ResultError(err)
@@ -78,6 +80,8 @@ func readblob(ctx sqlite3.Context, arg ...sqlite3.Value) {
7880
}
7981

8082
func writeblob(ctx sqlite3.Context, arg ...sqlite3.Value) {
83+
_ = arg[5] // bounds check
84+
8185
blob, err := getAuxBlob(ctx, arg, true)
8286
if err != nil {
8387
ctx.ResultError(err)

ext/regexp/regexp.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func load(ctx sqlite3.Context, i int, expr string) (*regexp.Regexp, error) {
7676
}
7777

7878
func regex(ctx sqlite3.Context, arg ...sqlite3.Value) {
79+
_ = arg[1] // bounds check
7980
re, err := load(ctx, 0, arg[0].Text())
8081
if err != nil {
8182
ctx.ResultError(err)
@@ -165,6 +166,8 @@ func regexInstr(ctx sqlite3.Context, arg ...sqlite3.Value) {
165166
}
166167

167168
func regexReplace(ctx sqlite3.Context, arg ...sqlite3.Value) {
169+
_ = arg[2] // bounds check
170+
168171
re, err := load(ctx, 1, arg[1].Text())
169172
if err != nil {
170173
ctx.ResultError(err)

ext/unicode/unicode.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func like(ctx sqlite3.Context, arg ...sqlite3.Value) {
189189
return
190190
}
191191
}
192+
_ = arg[1] // bounds check
192193

193194
type likeData struct {
194195
*regexp.Regexp

internal/util/mmap_unix.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ func (s *mmapState) new(ctx context.Context, mod api.Module, size int32) *Mapped
3939
// Save the newly allocated region.
4040
ptr := uint32(stack[0])
4141
buf := View(mod, ptr, uint64(size))
42-
addr := unsafe.Pointer(&buf[0])
43-
s.regions = append(s.regions, &MappedRegion{
42+
res := &MappedRegion{
4443
Ptr: ptr,
45-
addr: addr,
4644
size: size,
47-
})
48-
return s.regions[len(s.regions)-1]
45+
addr: unsafe.Pointer(&buf[0]),
46+
}
47+
s.regions = append(s.regions, res)
48+
return res
4949
}
5050

5151
type MappedRegion struct {

sqlite.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,11 @@ func (a *arena) mark() (reset func()) {
265265
ptrs := len(a.ptrs)
266266
next := a.next
267267
return func() {
268-
for _, ptr := range a.ptrs[ptrs:] {
268+
rest := a.ptrs[ptrs:]
269+
for _, ptr := range a.ptrs[:ptrs] {
269270
a.sqlt.free(ptr)
270271
}
271-
a.ptrs = a.ptrs[:ptrs]
272+
a.ptrs = rest
272273
a.next = next
273274
}
274275
}

0 commit comments

Comments
 (0)