Skip to content

Commit

Permalink
libckteec: fix memory allocation leakage on template serialization
Browse files Browse the repository at this point in the history
Fix memory allocation leakage with a call to release_serial_object()
to release obj2 before serialize_indirect_attribute() returns.

Link: #387
Fixes: e88c264 ("libckteec: helper function to serialize a attribute template")
Signed-off-by: Hoyong Jin <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
  • Loading branch information
hoyong2007 authored and jforissier committed Sep 24, 2024
1 parent 0293dd9 commit 49e646d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions libckteec/src/serialize_ck.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,19 @@ static CK_RV serialize_indirect_attribute(struct serializer *obj,
*/
rv = serialize_32b(obj, attribute->type);
if (rv)
return rv;
goto out;

rv = serialize_32b(obj, obj2.size);
if (rv)
return rv;
goto out;

rv = serialize_buffer(obj, obj2.buffer, obj2.size);
if (rv)
return rv;
goto out;

obj->item_count++;
out:
release_serial_object(&obj2);

return rv;
}
Expand Down

0 comments on commit 49e646d

Please sign in to comment.