From 54d8a3309923a06ade351da8fd5db7f22bd89e93 Mon Sep 17 00:00:00 2001 From: jettero Date: Sun, 23 Jul 2023 18:02:22 +0000 Subject: [PATCH] recompute ovecSlice The first two entries are always PCRE2_UNSET, then there's 2*(capture_top-1). At least that's how I read https://www.pcre.org/current/doc/html/pcre2callout.html --- pcre.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pcre.go b/pcre.go index a229b13..339a813 100644 --- a/pcre.go +++ b/pcre.go @@ -591,8 +591,8 @@ func (r *Regexp) SetCallout(fn func(cb *CalloutBlock) int32) error { calloutStrBytes := unsafe.Slice((*byte)(unsafe.Pointer(ccb.Fcallout_string)), ccb.Fcallout_string_length) cb.CalloutString = string(calloutStrBytes) - - ovecSlice := unsafe.Slice((*lib.Tsize_t)(unsafe.Pointer(ccb.Foffset_vector)), (ccb.Fcapture_top*2)-1) + + ovecSlice := unsafe.Slice((*lib.Tsize_t)(unsafe.Pointer(ccb.Foffset_vector)), 2+(ccb.Fcapture_top-1)*2) if len(ovecSlice) > 2 { ovecSlice = ovecSlice[2:] for i := 0; i < len(ovecSlice); i += 2 { -- 2.40.1