Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use assertion to ensure erroroffset return from pcre2_compile is with…
…in bounds (#460) When testing a patch for PCRE2, I found that due to a bug in my code, `pcre2_compile()` could return a totally invalid error offset. In case something similar ever happens again, I've added an assertion which will make it easier to notice the problem. It should be noted that the pcre2api manpage states: "Some errors are not detected until the whole pattern has been scanned; in these cases, the offset passed back is the length of the pattern." Since patterns are not always null-terminated, this means that `pattern + erroroffset` may sometimes point to uninitialized (or even unmapped) memory. However, it is still worthwhile to guard against other unexpected values being returned in `erroroffset`.
- Loading branch information