On Mon, Jun 30, 2014 at 21:26, Tobias Stoeckmann wrote:
> Hi,
> 
> this diff merges NetBSD's revision 1.20 into our tree:  There are
> some memory leaks in resetDosDirSection.
> 
> This is not a simple merge, I have added some things:
> 
> - rootDir was not properly freed in NetBSD's commit
> (actually it's put into a "free dir entry queue")
> - also free memory if root directory checks fail
> - I use goto's instead of rewriting the code every single time

> +fail:
> +     freeDosDirEntry(rootDir);
> +     rootDir = NULL;
> +fail_root:
> +     free(delbuf);
> +     delbuf = NULL;
> +fail_delbuf:
> +     free(buffer);
> +     buffer = NULL;
> +     return (FSFATAL);

I think it's safe to just have one goto label? free(NULL) is fine. a
small preference, but it seems less error prone when there's one cleanup
section that does what's necessary, as opposed to the jumping code
needing to determine where to jump each time.

Reply via email to