diff --git a/src/kernel/ally.c b/src/kernel/ally.c index 3ebc7c1ce..ed53cbce4 100644 --- a/src/kernel/ally.c +++ b/src/kernel/ally.c @@ -12,12 +12,10 @@ ally * ally_find(ally *al, const struct faction *f) { ally * ally_add(ally **al_p, struct faction *f) { ally * al; - if (f) { - while (*al_p) { - al = *al_p; - if (al->faction == f) return al; - al_p = &al->next; - } + while (*al_p) { + al = *al_p; + if (f && al->faction == f) return al; + al_p = &al->next; } al = (ally *)malloc(sizeof(ally)); al->faction = f; diff --git a/src/kernel/ally.test.c b/src/kernel/ally.test.c index fb35d25f7..c5c47298f 100644 --- a/src/kernel/ally.test.c +++ b/src/kernel/ally.test.c @@ -37,6 +37,7 @@ CuSuite *get_ally_suite(void) { CuSuite *suite = CuSuiteNew(); SUITE_ADD_TEST(suite, test_ally); + SUITE_ADD_TEST(suite, test_ally_null); return suite; }