Fix segfault when comparing mods

This commit is contained in:
MysterD 2021-08-02 00:33:34 -07:00
parent 1a2313bcce
commit 81b9638eaa
2 changed files with 5 additions and 2 deletions

View File

@ -151,7 +151,7 @@ void network_receive_join(struct Packet* p) {
string_builder_append(builder, "\\#c8c8c8\\Yours: "); string_builder_append(builder, "\\#c8c8c8\\Yours: ");
struct StringLinkedList* node = &gRegisteredMods; struct StringLinkedList* node = &gRegisteredMods;
bool first = true; bool first = true;
while (node != NULL) { while (node != NULL && node->string != NULL) {
string_builder_append(builder, first ? "\\#%s\\%s" : ", \\#%s\\%s", string_builder_append(builder, first ? "\\#%s\\%s" : ", \\#%s\\%s",
string_linked_list_contains(&head, node->string) ? "a0ffa0" : "ffa0a0" string_linked_list_contains(&head, node->string) ? "a0ffa0" : "ffa0a0"
, node->string); , node->string);
@ -162,7 +162,7 @@ void network_receive_join(struct Packet* p) {
string_builder_append(builder, "\n\n\\#c8c8c8\\Theirs: "); string_builder_append(builder, "\n\n\\#c8c8c8\\Theirs: ");
node = &head; node = &head;
first = true; first = true;
while (node != NULL) { while (node != NULL && node->string != NULL) {
string_builder_append(builder, first ? "\\#%s\\%s" : ", \\#%s\\%s", string_builder_append(builder, first ? "\\#%s\\%s" : ", \\#%s\\%s",
string_linked_list_contains(&gRegisteredMods, node->string) ? "a0ffa0" : "ffa0a0" string_linked_list_contains(&gRegisteredMods, node->string) ? "a0ffa0" : "ffa0a0"
, node->string); , node->string);

View File

@ -21,6 +21,9 @@ void string_linked_list_append(struct StringLinkedList* node, char* string) {
} }
bool string_linked_list_contains(struct StringLinkedList* node, char* string) { bool string_linked_list_contains(struct StringLinkedList* node, char* string) {
if (string == NULL) {
return false;
}
int length1 = strlen(string); int length1 = strlen(string);
while (node != NULL && node->string != NULL) { while (node != NULL && node->string != NULL) {
int length2 = strlen(node->string); int length2 = strlen(node->string);