[U-Boot] [PATCH] LZMA: Avoid free on null pointer.
Joakim Tjernlund
joakim.tjernlund at transmode.se
Sun Dec 5 11:27:27 CET 2010
Luigi Mantellini <luigi.mantellini.ml at gmail.com> wrote on 2010/12/05 11:19:58:
> On Sun, Dec 5, 2010 at 11:12 AM, Joakim Tjernlund
> <joakim.tjernlund at transmode.se> wrote:
> >>
> >> On structure Initialization, LZMA code tries to free the dictionary
> >> and probs buffers, also when these are null pointers. Add some
> >> check in order to prevent the free on null pointers.
> >>
> >> Signed-off-by: Luigi 'Comio' Mantellini <luigi.mantellini at idf-hit.com>
> >
> > Why not move these NULL checks inside LzmaDec_FreeProbs?
> > Then you don't have to litter the code with NULL checks
> > and LzmaDec_FreeProbs behaves like the standard free() function.
>
> I don't agree with this. We have problem only on initialization and
> should be the caller to check if buffer are already allocated (then
> free them) or not.
> This check is on the "init behavior" and not on "robustness" of free code.
Well, that is not how malloc/free works. It would be nice if LZMA
followed the same rules to minimize any confusion.
There may be other places that need this check too and you end up
with lots of NULL checks that just litters the code.
Jocke
More information about the U-Boot
mailing list