aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-22 09:56:09 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-22 09:56:09 +0200
commitdffc329bb6746c16e580497dda5996ab6e3c9712 (patch)
tree6bea70db107d4fc9e8456ceb29764dbda8e939d8
parentc0fa598f67188998e71910547a710691cf0c249c (diff)
downloadfref-dffc329bb6746c16e580497dda5996ab6e3c9712.tar.gz
Don't try to copy past end of field string
-rw-r--r--fref.lex6
1 files changed, 5 insertions, 1 deletions
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; \
}