Fix segmentation fault in soft_tfidf.c
Initialize local arrays suffixes1 and suffixes2 in function soft_tfidf_similarity_with_phrases_and_acronyms explicitly with NULL in order to prevent segmentation faults due to undefined initial values if ordinal_suffixes1 and ordinal_suffixes2 are NULL.
This commit is contained in:
committed by
GitHub
parent
d8c9847c56
commit
d6595aee9b
@@ -157,8 +157,8 @@ double soft_tfidf_similarity_with_phrases_and_acronyms(size_t num_tokens1, char
|
|||||||
uint32_array **t1_tokens_unicode = NULL;
|
uint32_array **t1_tokens_unicode = NULL;
|
||||||
uint32_array **t2_tokens_unicode = NULL;
|
uint32_array **t2_tokens_unicode = NULL;
|
||||||
|
|
||||||
uint32_array *t1_unicode;
|
uint32_array *t1_unicode = NULL;
|
||||||
uint32_array *t2_unicode;
|
uint32_array *t2_unicode = NULL;
|
||||||
|
|
||||||
int64_array *phrase_memberships_array1 = NULL;
|
int64_array *phrase_memberships_array1 = NULL;
|
||||||
int64_array *phrase_memberships_array2 = NULL;
|
int64_array *phrase_memberships_array2 = NULL;
|
||||||
@@ -232,8 +232,8 @@ double soft_tfidf_similarity_with_phrases_and_acronyms(size_t num_tokens1, char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t *suffixes1;
|
uint32_t *suffixes1 = NULL;
|
||||||
uint32_t *suffixes2;
|
uint32_t *suffixes2 = NULL;
|
||||||
|
|
||||||
if (ordinal_suffixes1 != NULL && ordinal_suffixes2 != NULL) {
|
if (ordinal_suffixes1 != NULL && ordinal_suffixes2 != NULL) {
|
||||||
suffixes1 = ordinal_suffixes1->a;
|
suffixes1 = ordinal_suffixes1->a;
|
||||||
@@ -589,4 +589,4 @@ return_soft_tfidf_score:
|
|||||||
|
|
||||||
double soft_tfidf_similarity(size_t num_tokens1, char **tokens1, double *token_scores1, size_t num_tokens2, char **tokens2, double *token_scores2, soft_tfidf_options_t options, size_t *num_matches) {
|
double soft_tfidf_similarity(size_t num_tokens1, char **tokens1, double *token_scores1, size_t num_tokens2, char **tokens2, double *token_scores2, soft_tfidf_options_t options, size_t *num_matches) {
|
||||||
return soft_tfidf_similarity_with_phrases_and_acronyms(num_tokens1, tokens1, token_scores1, NULL, NULL, num_tokens2, tokens2, token_scores2, NULL, NULL, NULL, NULL, options, num_matches);
|
return soft_tfidf_similarity_with_phrases_and_acronyms(num_tokens1, tokens1, token_scores1, NULL, NULL, num_tokens2, tokens2, token_scores2, NULL, NULL, NULL, NULL, options, num_matches);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user