summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6cbf8b0)
raw | patch | inline | side by side (parent: 6cbf8b0)
author | Junio C Hamano <gitster@pobox.com> | |
Thu, 3 Jul 2008 07:25:23 +0000 (00:25 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 3 Jul 2008 07:34:59 +0000 (00:34 -0700) |
The export_marks() function iterated over a (potentially sparsely
populated) hashtable, but it accessed it starting from offset 1 and one
element beyond the end.
Noticed by SungHyun Nam.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
populated) hashtable, but it accessed it starting from offset 1 and one
element beyond the end.
Noticed by SungHyun Nam.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-fast-export.c | patch | blob | history | |
decorate.c | patch | blob | history |
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 45786ef1b740c1e21c1cffeeea89cb0250f446c5..170b82e6ef18481430b5f83fd069b1726791e2de 100644 (file)
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
if (!f)
error("Unable to open marks file %s for writing", file);
- for (i = 0; i < idnums.size; ++i) {
- deco++;
- if (deco && deco->base && deco->base->type == 1) {
+ for (i = 0; i < idnums.size; i++) {
+ if (deco->base && deco->base->type == 1) {
mark = ptr_to_mark(deco->decoration);
fprintf(f, ":%u %s\n", mark, sha1_to_hex(deco->base->sha1));
}
+ deco++;
}
if (ferror(f) || fclose(f))
error("Unable to write marks file %s.", file);
}
-static void import_marks(char * input_file)
+static void import_marks(char *input_file)
{
char line[512];
FILE *f = fopen(input_file, "r");
line_end = strchr(line, '\n');
if (line[0] != ':' || !line_end)
die("corrupt mark line: %s", line);
- *line_end = 0;
+ *line_end = '\0';
mark = strtoumax(line + 1, &mark_end, 10);
if (!mark || mark_end == line + 1
diff --git a/decorate.c b/decorate.c
index 23f6b0040f1cda9a550e5b1d90589fa4a7f76eb5..d9668d2ef94c73e4a7a5602011ff13a9fd9d8c6a 100644 (file)
--- a/decorate.c
+++ b/decorate.c
{
int i;
int old_size = n->size;
- struct object_decoration *old_hash;
-
- old_size = n->size;
- old_hash = n->hash;
+ struct object_decoration *old_hash = n->hash;
n->size = (old_size + 1000) * 3 / 2;
n->hash = xcalloc(n->size, sizeof(struct object_decoration));