On Wednesday 16 December 2009, Thomas Kindler wrote:
>
> > for (int idx = 0; idx < 255; idx++)
> > {
> > void *p = malloc(0xFFFFFFFF);
> > }
> >
>
> That's why I said "reasonably sized". If you malloc() inside a file
> parser, malloc() based on unverified user input, or malloc() huge
> buffers, adding a check is an absolute necessity.
>
> These are cases with a clear action to take on error.
Not to disagree with the point that error handling can
be problematic ... but don't forget that for long running
programs such as servers (and "openocd" is a server), even
slow leaks cause serious problems over time.
The near-term implication there is that tracking what
happens with heap allocations -- are they freed when
appropriate? -- is worthwhile.
Personally, I've found it's easier to audit *ALL* uses
of each allocated memory block than to ignore obvious
goofs at allocation time. :)
- Dave
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development