[3.0] Backport var_InheritString leak fixes
This MR is a backport of !4754 (merged).
Contrary to the MR description of !4754 (merged), there is no var_InheritString
leak in src/network/tcp.c on 3.0. So 71de94b1 is not backported.
f00c62a8 is backported to prevent the next commit causing a use-after-free.
Also, 59bb141c, fee2c799, 4091808f, 3d5f48fa have been left out, because the code they touch is all 4.0 only for various reasons.
Additionally, 96868032 is left out because it doesn't fix a leak.
Finally, the change to oldrc.c isn't a backport of 5b79e0f9, but nevertheless fixes two leaks of the same variable. Since the change is different, it is "new" code.