Ref: #10818
This also tests for the memory leak bug fixed by parent commit b559ef6f. Ref: #10694 Closes https://github.com/curl/curl/pull/10712
b559ef6f