Memleak fixes

Backports of upstream memleak fixes. 
A bit of an inconsistency - gpointer here, void* in pending_req_free.