Re: [Linuxptp-users] Missing Sanity Checks for malloc()/calloc()/strdup() in linuxptp-1.5
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Xavier B. <xav...@fr...> - 2015-08-27 14:06:40
|
Under linux malloc() will only return NULL when you get out of address space, i.e. virtually never on a 64bits machine. Low memory situations are handled elsewhere (e.g. OOM killer). So I don't think checking malloc() for NULL is that wise. Xav Le 21/08/2015 18:43, Bill Parker a écrit : > This was a manual review of the code, I did not use something like > clang-analyzer to find these :) > > The wrapper approach makes sense as well (IMO). > > Bill > > On Fri, Aug 21, 2015 at 8:52 AM, Keller, Jacob E > <jac...@in... <mailto:jac...@in...>> wrote: > > On Fri, 2015-08-21 at 08:55 +0200, Miroslav Lichvar wrote: > > > I think an easier and cleaner approach would be to write > wrappers for > > the strdup/calloc/malloc/realloc functions which just send an error > > message and call exit(1) when the allocation fails, and use the > > wrappers everywhere in the code. > > > > Yea, I think this is probably a good call. We could use these > everywhere in the code base. > > Regards, > Jake > > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Linuxptp-users mailing list > Lin...@li... > https://lists.sourceforge.net/lists/listinfo/linuxptp-users |