Fix crash with very long lexemes; from upstream

This commit is contained in:
jasper 2020-04-20 07:30:20 +00:00
parent c99f78ced4
commit 7419dec1f6
2 changed files with 26 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.29 2020/02/16 14:44:18 sthen Exp $
# $OpenBSD: Makefile,v 1.30 2020/04/20 07:30:20 jasper Exp $
COMMENT= C-based regular expression scanner generator
@ -6,7 +6,7 @@ V= 1.3
DISTNAME= re2c-$V
EXTRACT_SUFX= .tar.xz
CATEGORIES= devel
REVISION= 0
REVISION= 1
HOMEPAGE= https://re2c.org/

View File

@ -0,0 +1,24 @@
$OpenBSD: patch-src_parse_scanner_cc,v 1.1 2020/04/20 07:30:20 jasper Exp $
Fix crash with very long lexemes
https://github.com/skvadrik/re2c/commit/c4603ba5ce229db83a2a4fb93e6d4b4e3ec3776a
Index: src/parse/scanner.cc
--- src/parse/scanner.cc.orig
+++ src/parse/scanner.cc
@@ -155,13 +155,14 @@ bool Scanner::fill(size_t need)
if (!buf) fatal("out of memory");
memmove(buf, tok, copy);
- shift_ptrs_and_fpos(buf - bot);
+ shift_ptrs_and_fpos(buf - tok);
delete [] bot;
bot = buf;
free = BSIZE - copy;
}
+ DASSERT(lim + free <= bot + BSIZE);
if (!read(free)) {
eof = lim;
memset(lim, 0, YYMAXFILL);