From 4b45abd1f000f62df9b624e393d9f3d62751a266 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Thu, 29 Jul 2010 18:03:35 -0700 Subject: [PATCH] Fix NULL pointer reference when using basic match If basic match has no tree of matches underneath then print_ematch would core dump. --- tc/m_ematch.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tc/m_ematch.c b/tc/m_ematch.c index 7f79a065a..4c3acf82b 100644 --- a/tc/m_ematch.c +++ b/tc/m_ematch.c @@ -449,12 +449,14 @@ static int print_ematch_list(FILE *fd, struct tcf_ematch_tree_hdr *hdr, if (tb == NULL) return -1; - if (parse_rtattr_nested(tb, hdr->nmatches, rta) < 0) - goto errout; + if (hdr->nmatches > 0) { + if (parse_rtattr_nested(tb, hdr->nmatches, rta) < 0) + goto errout; - fprintf(fd, "\n "); - if (print_ematch_seq(fd, tb, 1, 1) < 0) - goto errout; + fprintf(fd, "\n "); + if (print_ematch_seq(fd, tb, 1, 1) < 0) + goto errout; + } err = 0; errout: -- 2.47.2