summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-08-12 13:35:15 -0700
committerJeremy Allison <jra@samba.org>2008-08-12 13:35:15 -0700
commit8c630efd25cf17aff59448ca05c1b44a41964b16 (patch)
treeb9af194f5715c142bcb613e5bbadf9d06c523499 /examples
parent2462562b5c90bc1c46237cd980810b0a69cd116d (diff)
downloadsamba-8c630efd25cf17aff59448ca05c1b44a41964b16.tar.gz
Fix bug 5686 - libsmbclient segfaults with more than one SMBCCTX.
Here is a patch to allow many subsystems to be re-initialized. The only functional change I made was to remove the null context tracking, as the memory allocated here is designed to be left for the complete lifetime of the program. Freeing this early (when all smb contexts are destroyed) could crash other users of talloc. Jeremy.
Diffstat (limited to 'examples')
-rw-r--r--examples/libsmbclient/Makefile4
-rw-r--r--examples/libsmbclient/testctx.c17
2 files changed, 21 insertions, 0 deletions
diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile
index 7415f4f07ec..047addc8f7a 100644
--- a/examples/libsmbclient/Makefile
+++ b/examples/libsmbclient/Makefile
@@ -94,6 +94,10 @@ testwrite: testwrite.o
@echo Linking testwrite
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+testctx: testctx.o
+ @echo Linking testctx
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
+
smbsh:
make -C smbwrapper
diff --git a/examples/libsmbclient/testctx.c b/examples/libsmbclient/testctx.c
new file mode 100644
index 00000000000..8820bc8342e
--- /dev/null
+++ b/examples/libsmbclient/testctx.c
@@ -0,0 +1,17 @@
+#include <libsmbclient.h>
+
+void create_and_destroy_context (void)
+{
+ SMBCCTX *ctx;
+ ctx = smbc_new_context ();
+ smbc_init_context (ctx);
+
+ smbc_free_context (ctx, 1);
+}
+
+int main (int argc, char **argv)
+{
+ create_and_destroy_context ();
+ create_and_destroy_context ();
+ return 0;
+}