ui-blob: don't segfault when no path is given

It it possible to inspect blobs by specifying only the SHA-1, and CGit
provides links to do so, for example if a tag points directly at a blob.
In this case the path_items structure is never used, but creating it
still causes strlen to be run on a null pointer.  Fix this.

This error was introduced by commit c1633c6 (Update git to v1.7.6.5 -
2013-03-02).

Signed-off-by: John Keeping <john@keeping.me.uk>
This commit is contained in:
John Keeping 2013-04-07 15:06:23 +01:00 committed by Jason A. Donenfeld
parent b60e6bff75
commit 1c32e008c8

View File

@ -80,7 +80,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
struct commit *commit; struct commit *commit;
struct pathspec_item path_items = { struct pathspec_item path_items = {
.match = path, .match = path,
.len = strlen(path) .len = path ? strlen(path) : 0
}; };
struct pathspec paths = { struct pathspec paths = {
.nr = 1, .nr = 1,