diff options
author | Quentin Rameau <quinq@fifth.space> | 2016-04-29 14:01:45 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2016-04-29 15:54:57 +0200 |
commit | b8af751b0108edcad02bc59cec496b1d7808b0e1 (patch) | |
tree | 8855d432b300caae847f998cba7b79a94378adb1 | |
parent | 375d41dcce94106460f1b3855ebb295ccb138593 (diff) |
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.
-rw-r--r-- | stagit.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -709,13 +709,18 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path) fprintf(fp, "%juB", (uintmax_t)filesize); fputs("</td></tr>\n", fp); } else if (git_submodule_lookup(&module, repo, entryname) == 0) { - moduleurl = git_submodule_url(module); - fprintf(fp, "<tr><td>m---------</td><td><a class=\"module\" href=\"%s\">", - moduleurl); + fputs("<tr><td>m---------</td><td>", fp); + if ((moduleurl = git_submodule_url(module))) { + fprintf(fp, "<a class=\"module\" href=\"%s\">", + moduleurl); + } xmlencode(fp, entrypath, strlen(entrypath)); - fputs(" @", fp); - xmlencode(fp, moduleurl, strlen(moduleurl)); - fprintf(fp, "</a></td><td class=\"num\">0%c", + if (moduleurl) { + fputs(" @", fp); + xmlencode(fp, moduleurl, strlen(moduleurl)); + fputs("</a>", fp); + } + fprintf(fp, "</td><td class=\"num\">0%c", showlinecount ? 'L' : 'B'); git_submodule_free(module); fputs("</td></tr>\n", fp); |