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
commit03991ab0734ecbb87a75238d1356fbe0e5b1d38d (patch)
treec96c68c0f2fd8359c2250621f4b0938903ae385f /examples
parent9caabc441b3bfe860f9719cf64b6646f58a5cb59 (diff)
downloadsamba-03991ab0734ecbb87a75238d1356fbe0e5b1d38d.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. (This used to be commit 8c630efd25cf17aff59448ca05c1b44a41964b16)
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;
+}