aboutsummaryrefslogtreecommitdiff
path: root/lib/forlan.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2014-12-10 08:56:48 +0200
committerSergey Poznyakoff <gray@gnu.org>2014-12-10 08:56:48 +0200
commitbdd68868836f01ac766afa1a6c79a5f7d4287da6 (patch)
treed875e9fbf02575c9da52a2846ac00d09d5d3cefa /lib/forlan.c
parent85dfe24a45c65a9f414769fe059b1c5a06a3b176 (diff)
downloadeclat-bdd68868836f01ac766afa1a6c79a5f7d4287da6.tar.gz
eclat-bdd68868836f01ac766afa1a6c79a5f7d4287da6.tar.bz2
Fix coredump when comparing non-existing nodes.
* lib/forlan.c (coerce_value): Handle NULL nodes. (values_equal): Handle NULL strings. (dump_expr): Handle EQ and NE. * lib/forlanlex.l: Fix distinction before negative numeric and identifier. * etc/describe-security-groups.fln: ipProtocol == "-1" means "all". * tests/Makefile.am: Add new tests. * tests/testsuite.at: Likewise. * tests/comp00.at: New file. * tests/comp01.at: New file. * tests/comp02.at: New file. * tests/comp03.at: New file. * tests/comp04.at: New file. * tests/tforlan.c (main): Optionally read XML from standard input.
Diffstat (limited to 'lib/forlan.c')
-rw-r--r--lib/forlan.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/forlan.c b/lib/forlan.c
index 53365ae..209d70d 100644
--- a/lib/forlan.c
+++ b/lib/forlan.c
@@ -189,7 +189,9 @@ coerce_value(forlan_eval_env_t env, struct forlan_value *val,
break;
case forlan_value_node:
- if (val->v.node->type == grecs_node_stmt) {
+ if (!val->v.node)
+ val->v.string = NULL;
+ else if (val->v.node->type == grecs_node_stmt) {
struct grecs_txtacc *acc = grecs_txtacc_create();
grecs_txtacc_format_value(val->v.node->v.value,
0, acc);
@@ -260,7 +262,10 @@ values_equal(forlan_eval_env_t env,
switch (t) {
case T_S:
- res = strcmp(a->v.string, b->v.string) == 0;
+ if (!a->v.string || !b->v.string)
+ res = a->v.string == b->v.string;
+ else
+ res = strcmp(a->v.string, b->v.string) == 0;
break;
case T_B:
res = !!a->v.num == !!b->v.num;
@@ -524,7 +529,7 @@ free_type_expr(union forlan_node *p)
void
dump_expr(FILE *fp, union forlan_node *p, int *num, int lev)
{
- static char *opstr[] = { "NODE", "AND", "OR", "NOT" };
+ static char *opstr[] = { "NODE", "AND", "OR", "NOT", "EQ", "NE" };
fprintf(fp, "%s\n", opstr[p->expr.opcode]);
forlan_dump_node(fp, p->expr.arg[0], num, lev + 1);

Return to:

Send suggestions and report system problems to the System administrator.