From dffc329bb6746c16e580497dda5996ab6e3c9712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Thu, 22 Jul 2021 09:56:09 +0200 Subject: Don't try to copy past end of field string --- fref.lex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fref.lex b/fref.lex index e57eb01..2eaa19d 100644 --- a/fref.lex +++ b/fref.lex @@ -124,7 +124,11 @@ field() yytext[strcspn(yytext, "\n")] = 0; /* Fill corresponding field. */ - #define FI(s,m) if(strncmp(yytext,s,2) == 0 && (yytext += 3)){ \ + #define FI(s,m) if(strncmp(yytext,s,2) == 0){ \ + /* Don't copy empty field. */ \ + if(strlen(yytext) < 3) \ + return; \ + yytext += 3; \ strcpy(m, yytext); \ return; \ } -- cgit v1.2.3