Fix some memory leaks
Fix memory leaks in lib4d_sql and python p4d interface, particularly when dealing with large result sets