Skip to content

Codec issue when transferring lists with size 0 #66

@burgerkingorama

Description

@burgerkingorama

When transferring an empty list, the codec will be confused and all following structs are corrupted.

IDL:

interface Test {
	getData(out list<uint8>) -> void
}

The client shim code looks like this:

static void read_list_uint8_1_t_struct(erpc::Codec * codec, list_uint8_1_t * data) {
	codec->startReadList(&data->elementsCount);
	data->elements = (uint8_t *) erpc_malloc(data->elementsCount * sizeof(uint8_t));
	if (data->elements == NULL)
	{
		codec->updateStatus(kErpcStatus_MemoryError);
	}
[...]

Depending on the implementation of erpc_malloc the function may return NULL if the size to malloc is zero.

In the NULL case, which is our case is not an error the codec updates its state to error and all following struct are corrupted then.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions