Blame SOURCES/0010-segtree-stop-iteration-on-existing-elements-in-case-.patch

34625f
From d1145542184ec34ce19f383ea3d361d3287651ee Mon Sep 17 00:00:00 2001
34625f
From: Pablo Neira Ayuso <pablo@netfilter.org>
34625f
Date: Wed, 3 Oct 2018 16:19:47 +0200
34625f
Subject: [PATCH] segtree: stop iteration on existing elements in case range is
34625f
 found
34625f
34625f
No need to keep iterating once the range object has been allocated.
34625f
34625f
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
34625f
(cherry picked from commit a493147e60d350aca4197975281bf2ffe4cd1009)
34625f
Signed-off-by: Phil Sutter <psutter@redhat.com>
34625f
---
34625f
 src/segtree.c | 10 ++++++----
34625f
 1 file changed, 6 insertions(+), 4 deletions(-)
34625f
34625f
diff --git a/src/segtree.c b/src/segtree.c
34625f
index dc2554b72acf3..dc457d6bc1b7d 100644
34625f
--- a/src/segtree.c
34625f
+++ b/src/segtree.c
34625f
@@ -661,16 +661,18 @@ static struct expr *get_set_interval_find(const struct table *table,
34625f
 			range_expr_value_low(low, i);
34625f
 			range_expr_value_high(high, i);
34625f
 			if (mpz_cmp(left->key->value, low) >= 0 &&
34625f
-			    mpz_cmp(right->key->value, high) <= 0)
34625f
+			    mpz_cmp(right->key->value, high) <= 0) {
34625f
 				range = range_expr_alloc(&internal_location,
34625f
 							 expr_clone(left->key),
34625f
 							 expr_clone(right->key));
34625f
+				goto out;
34625f
+			}
34625f
 			break;
34625f
 		default:
34625f
 			break;
34625f
 		}
34625f
 	}
34625f
-
34625f
+out:
34625f
 	mpz_clear(low);
34625f
 	mpz_clear(high);
34625f
 
34625f
@@ -697,14 +699,14 @@ static struct expr *get_set_interval_end(const struct table *table,
34625f
 				range = range_expr_alloc(&internal_location,
34625f
 							 expr_clone(left->key),
34625f
 							 expr_clone(i->key->right));
34625f
-				break;
34625f
+				goto out;
34625f
 			}
34625f
 			break;
34625f
 		default:
34625f
 			break;
34625f
 		}
34625f
 	}
34625f
-
34625f
+out:
34625f
 	mpz_clear(low);
34625f
 	mpz_clear(high);
34625f
 
34625f
-- 
34625f
2.19.0
34625f