From c1d69b6067c896a56fa55c1fdb299cc78065d920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 24 Oct 2014 20:21:07 +0200 Subject: Do not crash when given an invalid search pattern --- text.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'text.c') diff --git a/text.c b/text.c index 004de22..9350819 100644 --- a/text.c +++ b/text.c @@ -1177,7 +1177,10 @@ Regex *text_regex_new(void) { int text_regex_compile(Regex *regex, const char *string, int cflags) { regex->string = string; - return regcomp(®ex->regex, string, cflags); + int r = regcomp(®ex->regex, string, cflags); + if (r) + regcomp(®ex->regex, "\0\0", 0); + return r; } void text_regex_free(Regex *r) { -- cgit v1.2.3