bug fix, invalid read when the title line is the empty

This commit is contained in:
rlar 2012-09-30 18:34:35 +02:00
parent 2506fe3858
commit f52ae6eccd
2 changed files with 11 additions and 0 deletions

View File

@ -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
}

View File

@ -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;
}