[flashrom] [PATCH] fix unchecked malloc calls
Uwe Hermann
uwe at hermann-uwe.de
Tue Jul 12 18:40:20 CEST 2011
On Fri, Jul 01, 2011 at 06:05:07AM +0200, Stefan Tauner wrote:
> compile tested only.
> btw... why dont we wrap malloc to automatically include these checks?
> there is probably a patch somewhere that adds totally awesome shutdown code in OOM cases,
> but afaics we just print a warning and exit right now... it is just stupid to do the checks in the real
> code then.
>
> Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
It's definately better than what we have now (no error checking at all), so:
Acked-by: Uwe Hermann <uwe at hermann-uwe.de>
A few notes for later though:
- We should call any shutdown function which may need to be called in
the respective places (and any free()s which may be needed).
- Later we should not exit(1) upon the error, but rather return an
error code instead (e.g. FL_ERR_MALLOC or similar), at least in all
public "API" functions which are meant to be in the upcoming
libflashrom.
- A small xmalloc() wrapper (or use another name) would indeed be nice, too,
but once we really return error codes etc. it's not really useful
anymore I think.
Uwe.
--
http://hermann-uwe.de | http://sigrok.org
http://randomprojects.org | http://unmaintained-free-software.org
More information about the flashrom
mailing list