commit 5742f90fdcbeda996e2dd69c5c3da2da99c44a41 from: Markus Uhlin date: Mon Dec 2 19:55:38 2024 UTC list_find: changed while loop commit - a5b487dfe4b4b065a6cde35f9385926719478c91 commit + 5742f90fdcbeda996e2dd69c5c3da2da99c44a41 blob - 5f93baf6b3997eaa995f14984ef20d3c77aaa876 blob + c76e64571f21888c8f8526ea847dfe68da1e5ab0 --- FICS/lists.c +++ FICS/lists.c @@ -89,11 +89,9 @@ list_find(int p, enum ListWhich l) rfree(tempList); return NULL; } - while (!feof(fp)) { - if (fgets(listmember, 100, fp) != NULL) { - listmember[strlen(listmember) - 1] = '\0'; - tempList->member[count++] = xstrdup(listmember); - } + while (fgets(listmember, ARRAY_SIZE(listmember), fp) != NULL) { + listmember[strcspn(listmember, "\n")] = '\0'; + tempList->member[count++] = xstrdup(listmember); } fclose(fp);