Hi,

(this probably belongs to the linuxptp-devel list)

On Thu, Aug 20, 2015 at 02:51:04PM -0700, Bill Parker wrote:
> Hello All,
> 
>     In reviewing source code in linuxptp-1.5, I found several instances
> where the return values for calls to malloc()/calloc()/strdup() are not
> checked for a return value of NULL, indicating failure.  This is in file
> 'timemaster.c', and the patch file below should address these issues,
> and also free()'s previously allocated memory in the order it was
> allocated:

Is this to fix warnings from a static code analyzer?

There are other places in the timemaster code where memory is
allocated, e.g. the parray_* and string_* function calls. If the code
tried to handle them all, it would be a mess.

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.

-- 
Miroslav Lichvar

------------------------------------------------------------------------------
_______________________________________________
Linuxptp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-users

Reply via email to