Skip to content

Commit

Permalink
Fixed memcpy for template (#352)
Browse files Browse the repository at this point in the history
* Fixed memcpy for template

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>

* Cover all memcpy for length 0

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>

---------

Signed-off-by: Cervenka Dusan <cervenka@acrios.com>
  • Loading branch information
Hadatko authored Apr 6, 2023
1 parent 88feacd commit e8e2e63
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions erpcgen/src/templates/c_coders.template
Original file line number Diff line number Diff line change
Expand Up @@ -60,22 +60,31 @@ if (({$info.sizeTemp} <= {$info.maxSize}) && ({$info.dataTemp} != NULL))
{% else %}
{% set indent = "" >%}
{% endif %}
{$indent}if ({$info.sizeTemp} > 0)
{$indent}{
{% if source == "server" || info.useMallocOnClientSide == true %}
{$indent}{$info.name} = (uint8_t *) erpc_malloc({$info.maxSize} * sizeof(uint8_t));
{% if generateAllocErrorChecks == true %}
{$indent}if (({$info.name} == NULL) && ({$info.sizeTemp} > 0))
{$indent}{
{$indent} codec->updateStatus(kErpcStatus_MemoryError);
{$indent} if ({$info.name} == NULL)
{$indent} {
{$indent} codec->updateStatus(kErpcStatus_MemoryError);
{$indent} }
{$indent} else
{$indent} {
{$indent} memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp});
{$indent} }
{% else -- generateAllocErrorChecks == true %}
{$indent} memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp});
{% endif -- generateAllocErrorChecks == true %}
{% else %}
{$indent} memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp});
{% endif %}
{$indent}}
{% if source == "server" || info.useMallocOnClientSide == true %}
{$indent}else
{$indent}{
{$indent} memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp});
{$indent} {$info.name} = NULL;
{$indent}}
{% else -- generateAllocErrorChecks == true %}
{$indent}memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp});
{% endif -- generateAllocErrorChecks == true %}
{% else %}
{$indent}memcpy({$info.name}, {$info.dataTemp}, {$info.sizeTemp});
{% endif %}
{% if info.maxSize != info.sizeTemp %}
}
Expand Down

0 comments on commit e8e2e63

Please sign in to comment.