Created attachment 7700 [details] Proposed patch for Samba 3.6.6 smbc_free_context(smbcctx) frees the global parameter structure if there is no other SMBCCTX. But next smbc_new_context() (SMBC_module_init() called by smbc_new_context()) does not initialize the new global parameter structure if $HOME environment variable is not defined. Thus following libsmbclient APIs call can NOT work correctly. I've created a test code: https://gist.github.com/3102379 You can see the problem as the below: $ wget -q https://gist.github.com/raw/3102379/310928ac6f4538f0debf7321d994c9c6529d5e99/test-libsmbclient-without-HOME-env.c $ gcc -lsmbclient test-libsmbclient-without-HOME-env.c $ echo $HOME /home/fumiyas $ ./a.out smb://server/share Test 1 Test 2 Test 3 Segmentation fault