From 63a550fa9e9b2c2a84b0769c683ccd183e10fefb Mon Sep 17 00:00:00 2001 From: Daniel Thayer Date: Wed, 5 Sep 2012 12:00:21 -0500 Subject: [PATCH] Fix a segfault when iterating over a set When iterating over a set with a "for" loop, bro would segfault when the number of index variables was less than required. Example: for ( [c1,c2] in s1 ) ... where s1 is defined as set[addr,port,count]. --- src/Stmt.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Stmt.cc b/src/Stmt.cc index 582323bf91..7d754d8e72 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -943,7 +943,10 @@ ForStmt::ForStmt(id_list* arg_loop_vars, Expr* loop_expr) { const type_list* indices = e->Type()->AsTableType()->IndexTypes(); if ( indices->length() != loop_vars->length() ) + { e->Error("wrong index size"); + return; + } for ( int i = 0; i < indices->length(); i++ ) {