From d871aaf5979a03effef54fc72e29716c2b952f91 Mon Sep 17 00:00:00 2001 From: kovzol Date: Wed, 1 Jan 2025 13:39:58 +0100 Subject: [PATCH] Fix segfault when OT fragment is missing --- statements/pbrst.y | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/statements/pbrst.y b/statements/pbrst.y index faf932e..5992cc8 100644 --- a/statements/pbrst.y +++ b/statements/pbrst.y @@ -350,6 +350,7 @@ void add_parseinfo(char *s, ...) { #define MAX_PARSEINFO_LINE_LENGTH 16384 char *line = malloc(MAX_PARSEINFO_LINE_LENGTH); vsprintf(line, s, ap); // create line + // printf("%s", line); // print line char *p1 = mystrcat(parseinfo, line); // store line free(parseinfo); parseinfo = p1; @@ -777,6 +778,12 @@ void check_cover(double cover) { } } } + if (oimin == INT_MAX) { + add_parseinfo(" none\n"); + add_parseinfo("%d,%d: error: OT headline %d %s %s has no corresponding fragments\n", yylineno, yycolumn, + i, books_s[i], infos_s[i]); + return; // avoid segfault later + } add_parseinfo(", union: [%d,%d]\n", oimin, oimax); // Compare headline interval with the union: int ot_headline_start = intervals[i][0];