why is this causing infinite while loop
Rule *curr2 = head;
Rule *r2 = NULL;

while (curr2 != NULL) {
    if (strcmp(curr2->target, token) == 0) {
        printf("yay\n");
        r2 = curr2;
    }
    curr2 = curr2->next_rule;
}

if (r2 == NULL) {
    r2 = malloc(sizeof(Rule));
    r2->target = strdup(token);
    r2->dependencies = NULL;
    r2->actions = a;
    r2->next_rule = NULL;
}

while (curr->next_rule != NULL) {
    printf("%s\n", curr->target);
    curr = curr->next_rule;
}

curr->next_rule = r2;