Prevent git-upload-pack segfault if object cannot be found
Signed-off-by: Carl Worth <cworth@cworth.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Carl Worth committed
Feb 17, 2006 at 16:14 UTC
b5b16990f8b074bd0481ced047b8f8bf66eee6dc
2 files changed
+6
-1
sha1_file.c
+3
-1
@@ -551,8 +551,10 @@ static void prepare_packed_git_one(char *objdir, int local)
551
sprintf(path, "%s/pack", objdir);
552
len = strlen(path);
553
dir = opendir(path);
554
- if (!dir)
554
+ if (!dir) {
555
+ fprintf(stderr, "unable to open object pack directory: %s: %s\n", path, strerror(errno));
556
return;
557
+ }
558
path[len++] = '/';
559
while ((de = readdir(dir)) != NULL) {
560
int namelen = strlen(de->d_name);
upload-pack.c
+3
@@ -216,6 +216,9 @@ static int send_ref(const char *refname, const unsigned char *sha1)
216
static char *capabilities = "multi_ack";
217
struct object *o = parse_object(sha1);
218
219
+ if (!o)
220
+ die("git-upload-pack: cannot find object %s:", sha1_to_hex(sha1));
221
+
222
if (capabilities)
223
packet_write(1, "%s %s%c%s\n", sha1_to_hex(sha1), refname,
224
0, capabilities);