projects
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
safe_fgets() - even more anal fgets()
[git.git]
/
pack-objects.c
diff --git
a/pack-objects.c
b/pack-objects.c
index
cde4afa
..
7d62477
100644
(file)
--- a/
pack-objects.c
+++ b/
pack-objects.c
@@
-905,11
+905,22
@@
int main(int argc, char **argv)
setup_progress_signal();
}
setup_progress_signal();
}
-
while (fgets(line, sizeof(line), stdin) != NULL
) {
+
for (;;
) {
unsigned int hash;
char *p;
unsigned char sha1[20];
unsigned int hash;
char *p;
unsigned char sha1[20];
+ if (!fgets(line, sizeof(line), stdin)) {
+ if (feof(stdin))
+ break;
+ if (!ferror(stdin))
+ die("fgets returned NULL, not EOF, not error!");
+ if (errno != EINTR)
+ die("fgets: %s", strerror(errno));
+ clearerr(stdin);
+ continue;
+ }
+
if (progress_update) {
fprintf(stderr, "Counting objects...%d\r", nr_objects);
progress_update = 0;
if (progress_update) {
fprintf(stderr, "Counting objects...%d\r", nr_objects);
progress_update = 0;