[Tarantool-patches] [PATCH v4 2/2] box: introduce _vsession_settings sysview

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sun Nov 24 18:27:58 MSK 2019


Hi! Thanks for the patch!

> diff --git a/src/box/session.cc b/src/box/session.cc
> index 461d1cf..93d8b42 100644
> --- a/src/box/session.cc
> +++ b/src/box/session.cc
> @@ -338,3 +341,131 @@ generic_session_sync(struct session *session)
> +
> +struct iterator *
> +session_options_create_iterator(struct index *index, enum iterator_type type,
> +				const char *key, uint32_t part_count)
> +{
> +	char *decoded_key = NULL;
> +	if (part_count > 0) {
> +		assert(part_count == 1);
> +		assert(mp_typeof(*key) == MP_STR);
> +		uint32_t len;
> +		const char *name = mp_decode_str(&key, &len);
> +		decoded_key = (char *)malloc(len + 1);
> +		if (decoded_key == NULL) {
> +			diag_set(OutOfMemory, len + 1, "malloc", "decoded_key");
> +			return NULL;
> +		}
> +		memcpy(decoded_key, name, len);
> +		decoded_key[len] = '\0';
> +	}
> +	struct space *space = space_cache_find(index->def->space_id);
> +	struct session_options_iterator *it =
> +		(session_options_iterator *)malloc(sizeof(*it));
> +	if (it == NULL) {

decoded_key leaks here. But heap OOM is such an unlikely event,
and is forgotten for be checked so often, that perhaps we should
reconsider moving this https://github.com/tarantool/tarantool/issues/3534
out of wish list and start using panic in new places. Probably
wrapped into a 'heap_alloc()' function (name is discussable).

I think, Kirill won't be against this.


More information about the Tarantool-patches mailing list