s3-client: Use the passed down memory context for cli_connect_nb()
With the patches coming before this patch, we can use main talloc
context to allocate the connections on and make sure we only free them
after we don't need them anymore.
This fixes a lot of memory leaks found by LeakSanitizer. One example is:
==838668==ERROR: LeakSanitizer: detected memory leaks
Indirect leak of 4784 byte(s) in 13 object(s) allocated from:
#0 0x7fdb1ef21c2b in malloc (/lib64/libasan.so.8+0x121c2b) (BuildId:
cbfe49f3b7600c4f194d4c54774c977296e9d98a)
#1 0x7fdb1ebbb6a0 in __talloc_with_prefix ../../lib/talloc/talloc.c:783
#2 0x7fdb1ebbcf75 in __talloc ../../lib/talloc/talloc.c:825
#3 0x7fdb1ebbcf75 in _talloc_named_const ../../lib/talloc/talloc.c:982
#4 0x7fdb1ebbcf75 in _talloc_zero ../../lib/talloc/talloc.c:2421
#5 0x7fdb1cfd1b25 in idr_pre_get ../../lib/util/idtree.c:98
#6 0x7fdb1cfd1b25 in idr_get_new_above_int ../../lib/util/idtree.c:202
#7 0x7fdb1cfd2c30 in idr_get_new_above ../../lib/util/idtree.c:368
#8 0x7fdb1de3246f in map_smb2_handle_to_fnum ../../source3/libsmb/cli_smb2_fnum.c:95
#9 0x7fdb1de3246f in cli_smb2_create_fnum_done ../../source3/libsmb/cli_smb2_fnum.c:438
#10 0x7fdb1dbaca05 in _tevent_req_notify_callback ../../lib/tevent/tevent_req.c:177
#11 0x7fdb1dbacc3c in tevent_req_finish ../../lib/tevent/tevent_req.c:234
#12 0x7fdb1dbacca4 in _tevent_req_done ../../lib/tevent/tevent_req.c:240
#13 0x7fdb1ed0eb35 in smb2cli_create_done ../../libcli/smb/smb2cli_create.c:483
#14 0x7fdb1dbaca05 in _tevent_req_notify_callback ../../lib/tevent/tevent_req.c:177
#15 0x7fdb1dbacc3c in tevent_req_finish ../../lib/tevent/tevent_req.c:234
#16 0x7fdb1dbacd74 in tevent_req_trigger ../../lib/tevent/tevent_req.c:291
#17 0x7fdb1dbaad1e in tevent_common_invoke_immediate_handler ../../lib/tevent/tevent_immediate.c:190
#18 0x7fdb1dbaad5b in tevent_common_loop_immediate ../../lib/tevent/tevent_immediate.c:236
#19 0x7fdb1dbbe42f in epoll_event_loop_once ../../lib/tevent/tevent_epoll.c:908
#20 0x7fdb1dbb7787 in std_event_loop_once ../../lib/tevent/tevent_standard.c:110
#21 0x7fdb1dba7466 in _tevent_loop_once ../../lib/tevent/tevent.c:860
#22 0x7fdb1dbad082 in tevent_req_poll ../../lib/tevent/tevent_req.c:342
#23 0x7fdb1eaa93d4 in tevent_req_poll_ntstatus ../../lib/util/tevent_ntstatus.c:109
#24 0x7fdb1de138bb in cli_list ../../source3/libsmb/clilist.c:1188
#25 0x000000239f0f in do_list ../../source3/client/client.c:853
#26 0x00000023a93a in cmd_dir ../../source3/client/client.c:936
#27 0x00000023f090 in process_stdin ../../source3/client/client.c:6215
#28 0x00000023f090 in process ../../source3/client/client.c:6269
#29 0x00000023f090 in main ../../source3/client/client.c:6811
#30 0x7fdb1ac2b2fa in __libc_start_call_main (/lib64/libc.so.6+0x2b2fa) (BuildId:
8523b213e7586a93ab00f6dd476418b1e521e62c)
#31 0x7ffd7d5613af ([stack]+0x3a3af)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Thu Nov 6 09:58:52 UTC 2025 on atb-devel-224