[PATCH] Fix new Coverity IDs
Jeremy Allison
jra at samba.org
Wed Jan 11 19:47:06 UTC 2017
On Wed, Jan 11, 2017 at 11:07:18AM -0800, Jeremy Allison wrote:
> 1501 num_rids = talloc_array_length(rids);
>
> so 'rids' is already initialized to NULL, but we then
> call talloc_array_length(rids) without checking if
> the return was NULL. This works (I think), but goes
> via:
>
> #define talloc_array_length(ctx) (talloc_get_size(ctx)/sizeof(*ctx))
>
> and talloc_get_size() is:
>
> _PUBLIC_ size_t talloc_get_size(const void *context)
> {
> struct talloc_chunk *tc;
>
> if (context == NULL) {
> context = null_context;
> }
> if (context == NULL) {
> return 0;
> }
>
> tc = talloc_chunk_from_ptr(context);
>
> return tc->size;
> }
>
> - which uses null_context - which can change what it returns
> if someone ever calls talloc_enable_null_tracking() !!!!!
Never mind. As Volker just pointed out to me on the phone,
null_context = _talloc_named_const(NULL, 0, "null_context"),
which will always return zero size anyway. Still,
that code shouldn't be in talloc_get_size().
Patch(es) to follow !
More information about the samba-technical
mailing list