Fix null pointer access for submodules in writefilestree
Do not try to set a link to submodules from bare repo as we can't get the actual url.
1 files changed, 11 insertions(+), 6 deletions(-) | |||
---|---|---|---|
M | stagit.c | +11 | -6 |
1@@ -709,13 +709,18 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path)
2 fprintf(fp, "%juB", (uintmax_t)filesize);
3 fputs("</td></tr>\n", fp);
4 } else if (git_submodule_lookup(&module, repo, entryname) == 0) {
5- moduleurl = git_submodule_url(module);
6- fprintf(fp, "<tr><td>m---------</td><td><a class=\"module\" href=\"%s\">",
7- moduleurl);
8+ fputs("<tr><td>m---------</td><td>", fp);
9+ if ((moduleurl = git_submodule_url(module))) {
10+ fprintf(fp, "<a class=\"module\" href=\"%s\">",
11+ moduleurl);
12+ }
13 xmlencode(fp, entrypath, strlen(entrypath));
14- fputs(" @", fp);
15- xmlencode(fp, moduleurl, strlen(moduleurl));
16- fprintf(fp, "</a></td><td class=\"num\">0%c",
17+ if (moduleurl) {
18+ fputs(" @", fp);
19+ xmlencode(fp, moduleurl, strlen(moduleurl));
20+ fputs("</a>", fp);
21+ }
22+ fprintf(fp, "</td><td class=\"num\">0%c",
23 showlinecount ? 'L' : 'B');
24 git_submodule_free(module);
25 fputs("</td></tr>\n", fp);