summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7e9ff00)
raw | patch | inline | side by side (parent: 7e9ff00)
author | Matthias Andree <matthias.andree@gmx.de> | |
Fri, 24 Jul 2009 08:17:13 +0000 (10:17 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 24 Jul 2009 16:12:26 +0000 (09:12 -0700) |
- Don't leak one FILE * on error per export_marks() call. Found with
cppcheck and reported by Martin Ettl.
- Abort the potentially long for(;idnums.size;) loop on write errors.
- Record error if fprintf() fails for reasons not required to set the
stream error indicator, such as ENOMEM.
- Add a trailing full-stop to error message when fopen() fails.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cppcheck and reported by Martin Ettl.
- Abort the potentially long for(;idnums.size;) loop on write errors.
- Record error if fprintf() fails for reasons not required to set the
stream error indicator, such as ENOMEM.
- Add a trailing full-stop to error message when fopen() fails.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fast-export.c | patch | blob | history |
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 6731713223d4df24614417cc4285cbee793151d3..9091481fd537c7bc855183232a75dfa6e386b8c3 100644 (file)
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
uint32_t mark;
struct object_decoration *deco = idnums.hash;
FILE *f;
+ int e = 0;
f = fopen(file, "w");
if (!f)
- error("Unable to open marks file %s for writing", file);
+ error("Unable to open marks file %s for writing.", file);
for (i = 0; i < idnums.size; i++) {
if (deco->base && deco->base->type == 1) {
mark = ptr_to_mark(deco->decoration);
- fprintf(f, ":%"PRIu32" %s\n", mark,
- sha1_to_hex(deco->base->sha1));
+ if (fprintf(f, ":%"PRIu32" %s\n", mark,
+ sha1_to_hex(deco->base->sha1)) < 0) {
+ e = 1;
+ break;
+ }
}
deco++;
}
- if (ferror(f) || fclose(f))
+ e |= ferror(f);
+ e |= fclose(f);
+ if (e)
error("Unable to write marks file %s.", file);
}