]> xenbits.xensource.com Git - xen.git/commit
tools: libxl: make it illegal to pass libxl__realloc(gc) a non-gc ptr
authorIan Campbell <ian.campbell@citrix.com>
Thu, 11 Feb 2016 09:23:54 +0000 (09:23 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 11 Feb 2016 15:36:19 +0000 (15:36 +0000)
commite5b16dba2e080b7201ae7ba1a4f301fa32902c1f
tree53791a38ea751aca4083e90a2377f55af6d7a315
parentf15348afe976d3c5e17fce2d2beb412bbae7475b
tools: libxl: make it illegal to pass libxl__realloc(gc) a non-gc ptr

That is, if gc is not NOGC and ptr is not NULL then ptr must be
associated with a gc.

Currently in this case the new_ptr would not be registered with any
gc, which Coverity rightly points out (in various different places)
would be a memory leak.

It would also be possible to fix this by adding a libxl__ptr_add() at
the same point, however semantically it seems like a programming error
to gc-realloc a pointer which is not associated with the gc in
question, so treat it as such.

Compile tested only, this change could expose latent bugs.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxl/libxl_internal.c
tools/libxl/libxl_internal.h