diff options
author | Reuben Thomas <rrt@sc3d.org> | 2022-12-08 21:14:50 +0000 |
---|---|---|
committer | Reuben Thomas <rrt@sc3d.org> | 2022-12-11 19:21:53 +0000 |
commit | 62a31ba6c92e684c90529a3ee6dcc2b1e4142a31 (patch) | |
tree | 19bacd761fc840e4c5f9c753b4220087949c351f | |
parent | 7cb091141dbad8e8b31c75b959296929cac13050 (diff) | |
download | enchant-62a31ba6c92e684c90529a3ee6dcc2b1e4142a31.tar.gz |
Fix potential NULL dereferences (thanks, GCC!)
Also fix some English in the API for enchant_dict_suggest, the implicated
function.
-rw-r--r-- | src/enchant.h | 4 | ||||
-rw-r--r-- | src/lib.c | 7 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/enchant.h b/src/enchant.h index 20e2d24..2211fa4 100644 --- a/src/enchant.h +++ b/src/enchant.h @@ -170,8 +170,8 @@ int enchant_dict_check (EnchantDict * dict, const char *const word, ssize_t len) * @len: The byte length of @word, or -1 for strlen (@word) * @out_n_suggs: The location to store the # of suggestions returned, or %null * - * Will return an %null value if any of those pre-conditions - * are not met. + * Will return a %null value if any of those pre-conditions + * is not met. * * Returns: A %null terminated list of UTF-8 encoded suggestions, or %null */ @@ -548,8 +548,11 @@ enchant_dict_suggest (EnchantDict * dict, const char *const word, ssize_t len, s if (n_suggs > 0) { suggs = g_new0 (char *, n_suggs + 1); - n_suggs = enchant_dict_merge_suggestions(suggs, 0, dict_suggs, n_dict_suggs); - n_suggs = enchant_dict_merge_suggestions(suggs, n_suggs, pwl_suggs, n_pwl_suggs); + n_suggs = 0; + if (dict_suggs != NULL) + n_suggs = enchant_dict_merge_suggestions(suggs, n_suggs, dict_suggs, n_dict_suggs); + if (pwl_suggs != NULL) + n_suggs = enchant_dict_merge_suggestions(suggs, n_suggs, pwl_suggs, n_pwl_suggs); } g_strfreev(dict_suggs); |