@@ -442,22 +442,22 @@ char *fossil_io_soap_normalize_slang(const char *text) {
442
442
const char * bad = FOSSIL_SOAP_SUGGESTIONS [i ].bad ;
443
443
const char * sugg = FOSSIL_SOAP_SUGGESTIONS [i ].suggested ;
444
444
445
- char * found = NULL ;
445
+ const char * found = NULL ;
446
446
while ((found = custom_strcasestr (result , bad )) != NULL ) {
447
- size_t offset = found - result ;
447
+ size_t offset = ( size_t )( found - result ) ;
448
448
size_t newlen = strlen (result ) - strlen (bad ) + strlen (sugg ) + 1 ;
449
-
449
+
450
450
char * temp = malloc (newlen );
451
451
if (!temp ) {
452
452
free (result );
453
453
return NULL ;
454
454
}
455
-
455
+
456
456
strncpy (temp , result , offset );
457
457
temp [offset ] = '\0' ;
458
458
strcat (temp , sugg );
459
- strcat (temp , found + strlen (bad ));
460
-
459
+ strcat (temp , result + offset + strlen (bad ));
460
+
461
461
free (result );
462
462
result = temp ;
463
463
}
@@ -531,22 +531,22 @@ char *fossil_io_soap_filter_offensive(const char *text) {
531
531
const char * bad = OFFENSIVE_WORDS [i ].offensive ;
532
532
const char * good = OFFENSIVE_WORDS [i ].replacement ;
533
533
534
- char * found = NULL ;
534
+ const char * found = NULL ;
535
535
while ((found = custom_strcasestr (result , bad )) != NULL ) {
536
- size_t offset = found - result ;
536
+ size_t offset = ( size_t )( found - result ) ;
537
537
size_t newlen = strlen (result ) - strlen (bad ) + strlen (good ) + 1 ;
538
-
538
+
539
539
char * temp = malloc (newlen );
540
540
if (!temp ) {
541
541
free (result );
542
542
return NULL ;
543
543
}
544
-
544
+
545
545
strncpy (temp , result , offset );
546
546
temp [offset ] = '\0' ;
547
547
strcat (temp , good );
548
- strcat (temp , found + strlen (bad ));
549
-
548
+ strcat (temp , result + offset + strlen (bad ));
549
+
550
550
free (result );
551
551
result = temp ;
552
552
}
0 commit comments