]> git.sur5r.net Git - bacula/bacula/commitdiff
Attempt to avoid client==NULL
authorKern Sibbald <kern@sibbald.com>
Sat, 26 Jul 2014 08:20:19 +0000 (10:20 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 26 Jul 2014 08:49:10 +0000 (10:49 +0200)
bacula/src/dird/backup.c
bacula/src/dird/job.c

index 25728b2c98df282ae3be3c728c269b719ab504c9..89109f2b281b61206d7a3303fa002c910c3f4bec 100644 (file)
@@ -464,7 +464,9 @@ bool do_backup(JCR *jcr)
       return false;
    }
    sd = jcr->store_bsock;
-   jcr->sd_calls_client = jcr->client->sd_calls_client;
+   if (jcr->client) {
+      jcr->sd_calls_client = jcr->client->sd_calls_client;
+   }
    /*
     * Note startup sequence of SD/FD is different depending on
     *  whether the SD listens (normal) or the SD calls the FD.
index 985469926783f7943d9b1046032adea634cfeb85..08c9fee330e9db5c28bd2d23eb497c3bf5b6bfa8 100644 (file)
@@ -437,6 +437,7 @@ static int cancel_inactive_job(UAContext *ua, JCR *jcr)
    JOB_DBR    jr;
    int        i;
    USTORE     store;
+   CLIENT     *client;
 
    if (!jcr->client) {
       memset(&cr, 0, sizeof(cr));
@@ -462,7 +463,15 @@ static int cancel_inactive_job(UAContext *ua, JCR *jcr)
       }
 
       if (acl_access_ok(ua, Client_ACL, cr.Name)) {
-         jcr->client = (CLIENT *)GetResWithName(R_CLIENT, cr.Name);
+         client = (CLIENT *)GetResWithName(R_CLIENT, cr.Name);
+         if (client) {
+            jcr->client = client;
+         } else {
+            Jmsg1(jcr, M_FATAL, 0, _("Client resource \"%s\" does not exist.\n"), cr.Name);
+            goto bail_out;
+         }
+      } else {
+         goto bail_out;
       }
    }
 
@@ -1347,6 +1356,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job)
       copy_rwstorage(jcr, job->pool->storage, _("Pool resource"));
    }
    jcr->client = job->client;
+   ASSERT2(jcr->client, "jcr->client==NULL!!!");
    if (!jcr->client_name) {
       jcr->client_name = get_pool_memory(PM_NAME);
    }