about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Keeping2013-04-07 15:06:23 +0100
committerJason A. Donenfeld2013-04-07 16:07:58 +0200
commit1c32e008c8fda46f812c38f46ae7515bcf8002ee (patch)
tree5dbda13c3fd12af82f7eaf739e6274680030d821
parentConvert pager navigation into a unordered list (diff)
downloadcgit-1c32e008c8fda46f812c38f46ae7515bcf8002ee.tar.gz
cgit-1c32e008c8fda46f812c38f46ae7515bcf8002ee.zip
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>
-rw-r--r--ui-blob.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ui-blob.c b/ui-blob.c index c59fbcb..7aec0b1 100644 --- a/ui-blob.c +++ b/ui-blob.c
@@ -80,7 +80,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head)
80 struct commit *commit; 80 struct commit *commit;
81 struct pathspec_item path_items = { 81 struct pathspec_item path_items = {
82 .match = path, 82 .match = path,
83 .len = strlen(path) 83 .len = path ? strlen(path) : 0
84 }; 84 };
85 struct pathspec paths = { 85 struct pathspec paths = {
86 .nr = 1, 86 .nr = 1,