--- /dev/null
+From af393297b65456d07122f3e372ee3985dc747f06 Mon Sep 17 00:00:00 2001
+From: Eric Bollengier <eric@eb.homelinux.org>
+Date: Wed, 9 Sep 2009 10:24:20 +0200
+Subject: [PATCH] Fix #1369 about segfault when using ExcludeDirContaining before defining Options{} block.
+
+---
+ bacula/src/dird/dird_conf.c | 6 ++++++
+ bacula/src/dird/dird_conf.h | 2 +-
+ bacula/src/dird/fd_cmds.c | 6 +++---
+ bacula/src/dird/inc_conf.c | 2 +-
+ 4 files changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c
+index d9995ad..0819e76 100644
+--- a/bacula/src/dird/dird_conf.c
++++ b/bacula/src/dird/dird_conf.c
+@@ -806,6 +806,9 @@ void dump_resource(int type, RES *reshdr, void sendit(void *sock, const char *fm
+ }
+ sendit(sock, " N\n");
+ }
++ if (incexe->ignoredir) {
++ sendit(sock, " Z %s\n", incexe->ignoredir);
++ }
+ for (j=0; j<incexe->name_list.size(); j++) {
+ sendit(sock, " I %s\n", incexe->name_list.get(j));
+ }
+@@ -1026,6 +1029,9 @@ static void free_incexe(INCEXE *incexe)
+ if (incexe->opts_list) {
+ free(incexe->opts_list);
+ }
++ if (incexe->ignoredir) {
++ free(incexe->ignoredir);
++ }
+ free(incexe);
+ }
+
+diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h
+index 231dfab..55706ec 100644
+--- a/bacula/src/dird/dird_conf.h
++++ b/bacula/src/dird/dird_conf.h
+@@ -462,7 +462,6 @@ struct FOPTS {
+ alist drivetype; /* drive type limitation */
+ char *reader; /* reader program */
+ char *writer; /* writer program */
+- char *ignoredir; /* ignoredir string */
+ char *plugin; /* plugin program */
+ };
+
+@@ -474,6 +473,7 @@ struct INCEXE {
+ int32_t num_opts; /* number of options items */
+ alist name_list; /* filename list -- holds char * */
+ alist plugin_list; /* filename list for plugins */
++ char *ignoredir; /* ignoredir string */
+ };
+
+ /*
+diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c
+index 71d9fc3..2ef63d9 100644
+--- a/bacula/src/dird/fd_cmds.c
++++ b/bacula/src/dird/fd_cmds.c
+@@ -354,6 +354,9 @@ static bool send_fileset(JCR *jcr)
+ ie = fileset->exclude_items[i];
+ fd->fsend("E\n");
+ }
++ if (ie->ignoredir) {
++ bnet_fsend(fd, "Z %s\n", ie->ignoredir);
++ }
+ for (j=0; j<ie->num_opts; j++) {
+ FOPTS *fo = ie->opts_list[j];
+ fd->fsend("O %s\n", fo->opts);
+@@ -399,9 +402,6 @@ static bool send_fileset(JCR *jcr)
+ if (fo->plugin) {
+ fd->fsend("G %s\n", fo->plugin);
+ }
+- if (fo->ignoredir) {
+- bnet_fsend(fd, "Z %s\n", fo->ignoredir);
+- }
+ if (fo->reader) {
+ fd->fsend("D %s\n", fo->reader);
+ }
+diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c
+index ef15d3f..aedde44 100644
+--- a/bacula/src/dird/inc_conf.c
++++ b/bacula/src/dird/inc_conf.c
+@@ -588,7 +588,7 @@ static void store_excludedir(LEX *lc, RES_ITEM2 *item, int index, int pass, bool
+ }
+ token = lex_get_token(lc, T_NAME);
+ if (pass == 1) {
+- res_incexe.current_opts->ignoredir = bstrdup(lc->str);
++ res_incexe.ignoredir = bstrdup(lc->str);
+ }
+ scan_to_eol(lc);
+ }
+--
+1.6.3.1
+