s4:torture: Do not segfault in torture_rpc_spoolss_printer_teardown_common()
authorAndreas Schneider <asn@samba.org>
Thu, 22 Jun 2017 08:25:09 +0000 (10:25 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 23 Jun 2017 19:00:19 +0000 (21:00 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Jun 23 21:00:19 CEST 2017 on sn-devel-144

source4/torture/rpc/spoolss.c

index 20d2f14c113ea3fb7200f34b5d6b1f03109d1248..14a43b97f6d6b177d776235a720045666dcd6e23 100644 (file)
@@ -8572,10 +8572,14 @@ static bool torture_rpc_spoolss_printer_teardown_common(struct torture_context *
 {
        bool found = false;
        struct dcerpc_pipe *p = t->spoolss_pipe;
-       struct dcerpc_binding_handle *b = p->binding_handle;
-       const char *printer_name = t->info2.printername;
+       struct dcerpc_binding_handle *b = NULL;
        const char *server_name_slash;
 
+       if (p == NULL) {
+               return true;
+       }
+       b = p->binding_handle;
+
        server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
 
        if (t->added_driver) {
@@ -8594,7 +8598,8 @@ static bool torture_rpc_spoolss_printer_teardown_common(struct torture_context *
                        "failed to delete printer driver via spoolss");
        }
 
-       if (p && !t->wellknown) {
+       if (!t->wellknown) {
+               const char *printer_name = t->info2.printername;
 
                torture_assert(tctx,
                        test_DeletePrinter(tctx, b, &t->handle),