From 03991ab0734ecbb87a75238d1356fbe0e5b1d38d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 12 Aug 2008 13:35:15 -0700 Subject: 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) --- examples/libsmbclient/Makefile | 4 ++++ examples/libsmbclient/testctx.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 examples/libsmbclient/testctx.c (limited to 'examples/libsmbclient') diff --git a/examples/libsmbclient/Makefile b/examples/libsmbclient/Makefile index 7415f4f07e..047addc8f7 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 0000000000..8820bc8342 --- /dev/null +++ b/examples/libsmbclient/testctx.c @@ -0,0 +1,17 @@ +#include + +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; +} -- cgit