Fixes for several memory leaks

Lukas Fleischer cgit at cryptocrack.de
Sun Apr 10 19:31:39 CEST 2011


On Thu, Apr 07, 2011 at 12:38:50PM +0200, Lars Hjemli wrote:
> On Thu, Apr 7, 2011 at 12:30, Lukas Fleischer <cgit at cryptocrack.de> wrote:
> > On Thu, Apr 07, 2011 at 12:15:19PM +0200, Lars Hjemli wrote:
> >> +++ b/ui-diff.c
> >> @@ -368,8 +368,10 @@ void cgit_print_diff(const char *new_rev, const char *old_r
> >>                 return;
> >>         }
> >>         commit = lookup_commit_reference(new_rev_sha1);
> >> -       if (!commit || parse_commit(commit))
> >> +       if (!commit || parse_commit(commit)) {
> >>                 cgit_print_error(fmt("Bad commit: %s", sha1_to_hex(new_rev_sha1)
> >> +               return;
> >> +       }
> >>
> >>         if (old_rev)
> >>                 get_sha1(old_rev, old_rev_sha1);
> >
> > Yeah, I wasn't sure since there are other "Bad commit" error handlers
> > below that do not "return;" as well, whereas all other error handlers
> > do. My assumption that this is intended and execution should continue in
> > this case (maybe to build the remaining page properly and display the
> > error message somewhere inbetween).
> 
> No, the two missing returns (I only saw the first, thanks for
> noticing) are simply bugs.

Rebased my "wip" branch, changing the "Avoid null pointer dereference in
cgit_print_diff()." to what you proposed and removing the trim_end()
patch for now.




More information about the CGit mailing list