1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

be_local: cope with a desc file without trailing newline

We checked the (fgets == NULL and !feof) case, but never actually bailed
out of the loop if we were at the end of the file, causing infinite
looping.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-09-18 17:32:15 -05:00
parent 86d9fcbfff
commit 41d8deff88

View File

@ -500,14 +500,18 @@ static char *get_pkgpath(alpm_db_t *db, alpm_pkg_t *info)
#define READ_AND_STORE_ALL(f) do { \
char *linedup; \
if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) goto error; \
if(fgets(line, sizeof(line), fp) == NULL) {\
if(!feof(fp)) goto error; else break; \
} \
if(_alpm_strip_newline(line) == 0) break; \
STRDUP(linedup, line, goto error); \
f = alpm_list_add(f, linedup); \
} while(1) /* note the while(1) and not (0) */
#define READ_AND_SPLITDEP(f) do { \
if(fgets(line, sizeof(line), fp) == NULL && !feof(fp)) goto error; \
if(fgets(line, sizeof(line), fp) == NULL) {\
if(!feof(fp)) goto error; else break; \
} \
if(_alpm_strip_newline(line) == 0) break; \
f = alpm_list_add(f, _alpm_splitdep(line)); \
} while(1) /* note the while(1) and not (0) */