]> gitweb.ps.run Git - ps-cgit/blobdiff - ui-atom.c
ui-atom: fix resource leak: free before return
[ps-cgit] / ui-atom.c
index b22d745a92c5b8e4fe414337b48a7139bbce2f18..fab4b0fd8d50bbb83b2129227394e65f606f058a 100644 (file)
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -80,7 +80,7 @@ static void add_entry(struct commit *commit, const char *host)
 
 void cgit_print_atom(char *tip, char *path, int max_count)
 {
-       const char *host;
+       char *host;
        const char *argv[] = {NULL, tip, NULL, NULL, NULL};
        struct commit *commit;
        struct rev_info rev;
@@ -125,18 +125,20 @@ void cgit_print_atom(char *tip, char *path, int max_count)
        html_txt(ctx.repo->desc);
        html("</subtitle>\n");
        if (host) {
+               char *repourl = cgit_repourl(ctx.repo->url);
                html("<link rel='alternate' type='text/html' href='");
                html(cgit_httpscheme());
                html_attr(host);
-               html_attr(cgit_repourl(ctx.repo->url));
+               html_attr(repourl);
                html("'/>\n");
+               free(repourl);
        }
        while ((commit = get_revision(&rev)) != NULL) {
                add_entry(commit, host);
-               free(commit->buffer);
-               commit->buffer = NULL;
+               free_commit_buffer(commit);
                free_commit_list(commit->parents);
                commit->parents = NULL;
        }
        html("</feed>\n");
+       free(host);
 }