Skip to content

Commit 18546ef

Browse files
apply safe guards to soap
1 parent 59ff79f commit 18546ef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

code/logic/soap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static void replace_substring_case_insensitive(char *str, const char *old_substr
106106
}
107107

108108
void fossil_soap_sanitize(char *input) {
109-
if (input == NULL) return;
109+
if (input == NULL || *input == '\0') return;
110110

111111
// Perform single-threaded sanitization
112112
for (size_t i = 0; i < sizeof(offensive_words) / sizeof(offensive_words[0]); ++i) {
@@ -118,7 +118,7 @@ void fossil_soap_sanitize(char *input) {
118118

119119
// Function to check if a word is an offensive word or phrase
120120
int32_t fossil_soap_is_offensive(const char *word) {
121-
if (word == NULL) return EXIT_SUCCESS;
121+
if (word == NULL || *word == '\0') return EXIT_SUCCESS;
122122

123123
for (size_t i = 0; i < sizeof(offensive_words) / sizeof(offensive_words[0]); ++i) {
124124
if (strcasecmp(word, offensive_words[i]) == 0) {
@@ -130,7 +130,7 @@ int32_t fossil_soap_is_offensive(const char *word) {
130130

131131
// Function to get the number of offensive words found in a string
132132
int32_t fossil_soap_count_offensive(const char *input) {
133-
if (input == NULL) return 0;
133+
if (input == NULL || *input == '\0') return 0;
134134

135135
int count = 0;
136136
char *copy = _custom_fossil_strdup(input);

0 commit comments

Comments
 (0)