From b8af751b0108edcad02bc59cec496b1d7808b0e1 Mon Sep 17 00:00:00 2001 From: Quentin Rameau Date: Fri, 29 Apr 2016 14:01:45 +0200 Subject: [PATCH] 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. --- stagit.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/stagit.c b/stagit.c index 7b16f32..206dca1 100644 --- a/stagit.c +++ b/stagit.c @@ -709,13 +709,18 @@ writefilestree(FILE *fp, git_tree *tree, const char *branch, const char *path) fprintf(fp, "%juB", (uintmax_t)filesize); fputs("\n", fp); } else if (git_submodule_lookup(&module, repo, entryname) == 0) { - moduleurl = git_submodule_url(module); - fprintf(fp, "m---------", - moduleurl); + fputs("m---------", fp); + if ((moduleurl = git_submodule_url(module))) { + fprintf(fp, "", + moduleurl); + } xmlencode(fp, entrypath, strlen(entrypath)); - fputs(" @", fp); - xmlencode(fp, moduleurl, strlen(moduleurl)); - fprintf(fp, "0%c", + if (moduleurl) { + fputs(" @", fp); + xmlencode(fp, moduleurl, strlen(moduleurl)); + fputs("", fp); + } + fprintf(fp, "0%c", showlinecount ? 'L' : 'B'); git_submodule_free(module); fputs("\n", fp); -- libgit2 1.1.1