From c27d97243bb3cb28a11bb777a586e6453cd1fed8 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 24 Jul 2012 18:51:27 +0200 Subject: [PATCH] Avoid infinite loops when regex matches an empty string --- xsv.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xsv.c b/xsv.c index 545a39e..0493312 100644 --- a/xsv.c +++ b/xsv.c @@ -416,6 +416,12 @@ static int regex_read(struct format *fmt) } return 1; } + if (ovec[0] == ovec[1]) { + warn(fmt, "Regular expression matched an empty separator"); + new_field(i); + in_field->len = n - i; + return 1; + } if (!fmt->sloppy || ovec[0]) { new_field(i); in_field->len = ovec[0] - i; -- 2.39.5