aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2015-01-15 14:12:39 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2015-01-15 14:12:39 +0200
commitbe602072f517f841ee29a76f8119b030ec3d869b (patch)
tree9278a65c21849090a8ea0cb5515ecc6775b3b19b /src
parentd18d2687d74b27583e3d09e3ff719f1e073c1732 (diff)
downloadgrecs-be602072f517f841ee29a76f8119b030ec3d869b.tar.gz
grecs-be602072f517f841ee29a76f8119b030ec3d869b.tar.bz2
Bugfix in node formatting code
* src/format.c (grecs_format_node_path) (grecs_format_node_path): don't coredump on NULL values.
Diffstat (limited to 'src')
-rw-r--r--src/format.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/format.c b/src/format.c
index d010729..cff4019 100644
--- a/src/format.c
+++ b/src/format.c
@@ -1,8 +1,8 @@
/* grecs - Gray's Extensible Configuration System
- Copyright (C) 2007-2012 Sergey Poznyakoff
+ Copyright (C) 2007-2015 Sergey Poznyakoff
Grecs is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
@@ -239,12 +239,17 @@ grecs_format_locus(grecs_locus_t *locus, struct grecs_format_closure *clos)
void
grecs_format_node_path(struct grecs_node *node, int flags,
struct grecs_format_closure *clos)
{
char delim[2] = ".";
+ if (!node) {
+ clos->fmtfun("NULL", clos->data);
+ return;
+ }
+
if (node->up)
grecs_format_node_path(node->up, flags, clos);
if (node->type == grecs_node_root)
return;
if (flags & _GRECS_NODE_MASK_DELIM)
delim[0] = flags & _GRECS_NODE_MASK_DELIM;
@@ -318,12 +323,17 @@ grecs_format_node(struct grecs_node *node, int flags,
if (!(flags & _GRECS_NODE_MASK_OUTPUT)) {
errno = EINVAL;
return 1;
}
+ if (!node) {
+ clos->fmtfun("NULL", clos->data);
+ return 0;
+ }
+
switch (node->type) {
case grecs_node_root:
case grecs_node_block:
if (flags & GRECS_NODE_FLAG_DESCEND) {
for (node = node->down; node; node = node->next) {
grecs_format_node(node, flags, clos);

Return to:

Send suggestions and report system problems to the System administrator.