Commit 09c07ac
authored
Small improvement to combination of substitution callout + overflow (#637)
I reckon that callers are assuming that when you use the PCRE2_SUBSTITUTE_OVERFLOW_LENGTH option, it will calculate the entire memory requirement in one go. Just two calls should be sufficient (rather than needing to loop with a gradually-increasing buffer size).
However, with a substitution callout this is not true. If you call once with PCRE2_SUBSTITUTE_OVERFLOW_LENGTH, the buffer length returned might still not be sufficient for the second call to succeed.
This is because the callout might not be called the first time, but the second time it will be called and can affect control flow, by requiring even more buffer to be used. This occurs even if the callout is completely stateless, idempotent and well-behaved.
This fix ensures that when we skip a callout (due to overflow), we still request enough buffer size for either option that the callout might return.1 parent f15bdd3 commit 09c07ac
File tree
6 files changed
+334
-139
lines changed- doc
- html
- src
- testdata
6 files changed
+334
-139
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4048 | 4048 | | |
4049 | 4049 | | |
4050 | 4050 | | |
4051 | | - | |
4052 | | - | |
4053 | | - | |
| 4051 | + | |
| 4052 | + | |
| 4053 | + | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
| 4059 | + | |
| 4060 | + | |
| 4061 | + | |
| 4062 | + | |
4054 | 4063 | | |
4055 | 4064 | | |
4056 | 4065 | | |
| |||
0 commit comments