capi_ctrl, capi_vtrace: check for NULL after allocating and free it