aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-11 10:32:31 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-11 10:32:31 +0200
commit19158a21183d28f4c2abfa5ddbcd30a86bd17c47 (patch)
treeb04081b34c2739a1e2f3afc16998040dc4eb3284 /text.c
parent9802e289c61e68e262a173063f14438ae12b32dd (diff)
downloadvis-19158a21183d28f4c2abfa5ddbcd30a86bd17c47.tar.gz
vis-19158a21183d28f4c2abfa5ddbcd30a86bd17c47.tar.xz
Avoid segfault if no previous search has been performed
Diffstat (limited to 'text.c')
-rw-r--r--text.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/text.c b/text.c
index 39d47cc..92a0644 100644
--- a/text.c
+++ b/text.c
@@ -1048,7 +1048,11 @@ const char *text_filename(Text *txt) {
}
Regex *text_regex_new(void) {
- return calloc(1, sizeof(Regex));
+ Regex *r = calloc(1, sizeof(Regex));
+ if (!r)
+ return NULL;
+ regcomp(&r->regex, "\0\0", 0); /* this should not match anything */
+ return r;
}
int text_regex_compile(Regex *regex, const char *string, int cflags) {