--- /dev/null
+
+ This patch can be applied to version 3.0.1 and should fix
+ a crash in the SD that occurs after canceling a job.
+ This should fix bug #1298.
+
+ Apply it to version 3.0.1 with:
+
+ cd <bacula-source>
+ patch -p0 <3.0.1-cancel-sd.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+
+Index: src/stored/reserve.c
+===================================================================
+--- src/stored/reserve.c (revision 8892)
++++ src/stored/reserve.c (working copy)
+@@ -755,6 +755,9 @@
+ bool ok = false;
+
+ ASSERT(dcr);
++ if (job_canceled(jcr)) {
++ return false;
++ }
+
+ dev->dlock();
+
+@@ -809,6 +812,9 @@
+ bool ok = false;
+
+ ASSERT(dcr);
++ if (job_canceled(jcr)) {
++ return false;
++ }
+
+ dev->dlock();
+
+Index: src/stored/spool.c
+===================================================================
+--- src/stored/spool.c (revision 8892)
++++ src/stored/spool.c (working copy)
+@@ -436,6 +436,9 @@
+ bool despool = false;
+ DEV_BLOCK *block = dcr->block;
+
++ if (job_canceled(dcr->jcr)) {
++ return false;
++ }
+ ASSERT(block->binbuf == ((uint32_t) (block->bufp - block->buf)));
+ if (block->binbuf <= WRITE_BLKHDR_LENGTH) { /* Does block have data in it? */
+ return true;
+Index: src/stored/vol_mgr.c
+===================================================================
+--- src/stored/vol_mgr.c (revision 8892)
++++ src/stored/vol_mgr.c (working copy)
+@@ -344,6 +344,9 @@
+ VOLRES *vol, *nvol;
+ DEVICE * volatile dev = dcr->dev;
+
++ if (job_canceled(dcr->jcr)) {
++ return NULL;
++ }
+ ASSERT(dev != NULL);
+
+ Dmsg2(dbglvl, "enter reserve_volume=%s drive=%s\n", VolumeName,
+@@ -701,6 +704,9 @@
+ bool rtn = true;
+ VOLRES *vol;
+
++ if (job_canceled(jcr)) {
++ return false;
++ }
+ lock_volumes();
+ vol = find_volume(VolumeName);
+ if (!vol) {
+Index: src/stored/askdir.c
+===================================================================
+--- src/stored/askdir.c (revision 8892)
++++ src/stored/askdir.c (working copy)
+@@ -494,6 +494,9 @@
+ JCR *jcr = dcr->jcr;
+ bool got_vol = false;
+
++ if (job_canceled(jcr)) {
++ return false;
++ }
+ Dmsg0(400, "enter dir_ask_sysop_to_create_appendable_volume\n");
+ ASSERT(dev->blocked());
+ for ( ;; ) {
+Index: src/stored/block.c
+===================================================================
+--- src/stored/block.c (revision 8892)
++++ src/stored/block.c (working copy)
+@@ -415,6 +415,9 @@
+ empty_block(block);
+ return true;
+ #endif
++ if (job_canceled(jcr)) {
++ return false;
++ }
+ ASSERT(block->binbuf == ((uint32_t) (block->bufp - block->buf)));
+ ASSERT(dev->is_open());
+
+@@ -935,6 +938,9 @@
+ DEVICE *dev = dcr->dev;
+ DEV_BLOCK *block = dcr->block;
+
++ if (job_canceled(jcr)) {
++ return false;
++ }
+ ASSERT(dev->is_open());
+
+ if (dev->at_eot()) {