From f52ae6eccd23c4b76e399d82a31500a1df381921 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 30 Sep 2012 18:34:35 +0200 Subject: [PATCH] bug fix, invalid read when the title line is the empty --- src/frontend/inp.c | 7 +++++++ src/frontend/parser/complete.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 4d6de50df..975ac4769 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -939,7 +939,14 @@ inp_dodeck( } // if (!noparse) . . . /* add title of deck to data base */ + /* this won't work if the title is the empty string + * cp_addkword() doesn't work for tt === "" + * since CT_CKTNAMES doesn't seem to be used anywhere + * I've disabled this piece. + */ +#if 0 cp_addkword(CT_CKTNAMES, tt); +#endif } diff --git a/src/frontend/parser/complete.c b/src/frontend/parser/complete.c index 0163faed3..5e89a6da7 100644 --- a/src/frontend/parser/complete.c +++ b/src/frontend/parser/complete.c @@ -599,6 +599,10 @@ clookup(register char *word, struct ccom **dd, bool pref, bool create) buf[0] = *word; buf[1] = '\0'; place->cc_name = copy(buf); + if (word[0] == '\0') { + fprintf(stderr, "ERROR, internal error, clookup() needs fixing to process the empty string\n"); + controlled_exit(EXIT_FAILURE); + } if (word[1]) place->cc_invalid = 1; }