fix terminating NUL on the captured string