Skip to content

Commit

Permalink
Avoid null-pointer deref in python unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Mar 27, 2024
1 parent fdeb108 commit 45a5874
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions link-grammar/dict-common/print-dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -1073,8 +1073,6 @@ static char *display_word_split(Dictionary dict,
char * (*display)(Dictionary, const char *, const void **),
const char **arg)
{
Sentence sent;

if ('\0' == *word) return NULL; /* avoid trying null strings */

/* SUBSCRIPT_DOT in a sentence word is not interpreted as SUBSCRIPT_MARK,
Expand All @@ -1088,7 +1086,7 @@ static char *display_word_split(Dictionary dict,

int spell_option = parse_options_get_spell_guess(opts);
parse_options_set_spell_guess(opts, 0);
sent = sentence_create(pword, dict);
Sentence sent = sentence_create(pword, dict);

if (pword[0] == '<' && (strchr(pword, '>') != NULL) &&
((strchr(pword, '>')[1] == '\0') ||
Expand Down
2 changes: 1 addition & 1 deletion link-grammar/prepare/build-disjuncts.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ Disjunct *build_disjuncts_for_exp(Sentence sent, Exp* exp, const char *word,
pool_reuse(ct.Tconnector_pool);

/* We are done, in the concvetional case. */
if (0 == opts->max_disjuncts) return dis;
if (NULL == opts || 0 == opts->max_disjuncts) return dis;

/* If there are more than the allowed number of disjuncts,
* then randomly discard some of them. The discard is done
Expand Down

0 comments on commit 45a5874

Please sign in to comment.