Skip to content

Commit

Permalink
print_config: check if resource it used at all
Browse files Browse the repository at this point in the history
prevents a segfault on director, when running with debug >= 900

Signed-off-by: Marco van Wieringen <marco.van.wieringen@bareos.com>
  • Loading branch information
joergsteffens authored and Marco van Wieringen committed Sep 26, 2014
1 parent 432830f commit e4d36a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/parse_conf.h
Expand Up @@ -116,8 +116,8 @@ class RES {
char *name; /* resource name */
char *desc; /* resource description */
uint32_t rcode; /* resource id or type */
int32_t refcnt; /* reference count for releasing */
char item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
int32_t refcnt; /* reference count for releasing */
char item_present[MAX_RES_ITEMS]; /* set if item is present in conf file */
};

/*
Expand Down
8 changes: 8 additions & 0 deletions src/lib/res.c
Expand Up @@ -1398,6 +1398,14 @@ bool BRSRES::print_config(POOL_MEM &buff)
int i = 0;
int rindex = this->hdr.rcode - my_config->m_r_first;

/*
* If entry is not used, then there is nothing to print.
*/
if (this->hdr.rcode < my_config->m_r_first ||
this->hdr.refcnt <= 0) {
return true;
}

/*
* Make sure the resource class has any items.
*/
Expand Down

0 comments on commit e4d36a1

Please sign in to comment.