From b15a61ffc934e5e4f558de69505f904b4de0d2e3 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 23 Oct 2015 20:03:07 +0000 Subject: [PATCH] LP#1509479: set a limit on loops in QP's decompose() method Following a suggestion of Dan Scott's, add a pair of suspenders to the belt and enforce an arbitrary limit of 1000 passes through QP->decompse(). Signed-off-by: Galen Charlton Signed-off-by: Dan Scott --- .../src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm index ba90f18eff..7f1f2356c6 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/QueryParser.pm @@ -951,8 +951,14 @@ sub decompose { my $remainder = ''; + my $loops = 0; while (!$remainder) { - warn ' 'x$recursing."Start of the loop. last_type: $last_type, joiner: ".$struct->joiner.", struct: $struct\n" if $self->debug; + $loops++; + warn ' 'x$recursing."Start of the loop. loop: $loops last_type: $last_type, joiner: ".$struct->joiner.", struct: $struct\n" if $self->debug; + if ($loops > 1000) { # the most magical of numbers... + warn ' 'x$recursing." got to $loops loops; aborting\n" if $self->debug; + last; + } if ($last_type eq 'FEND' and $fstart and $fstart != $struct) { # fall back further $remainder = $_; last; -- 2.11.0