Fix segfault when comparing mods

This commit is contained in:
MysterD 2021-08-02 00:33:34 -07:00
parent c18413ed2a
commit f9a144b6c1
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: ");
struct StringLinkedList* node = &gRegisteredMods;
bool first = true;
while (node != NULL) {
while (node != NULL && node->string != NULL) {
string_builder_append(builder, first ? "\\#%s\\%s" : ", \\#%s\\%s",
string_linked_list_contains(&head, node->string) ? "a0ffa0" : "ffa0a0"
, node->string);
@ -162,7 +162,7 @@ void network_receive_join(struct Packet* p) {
string_builder_append(builder, "\n\n\\#c8c8c8\\Theirs: ");
node = &head;
first = true;
while (node != NULL) {
while (node != NULL && node->string != NULL) {
string_builder_append(builder, first ? "\\#%s\\%s" : ", \\#%s\\%s",
string_linked_list_contains(&gRegisteredMods, node->string) ? "a0ffa0" : "ffa0a0"
, 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) {
if (string == NULL) {
return false;
}
int length1 = strlen(string);
while (node != NULL && node->string != NULL) {
int length2 = strlen(node->string);