Fix leak in ASN1 code for unique ID

Drop unnecessary call to ASN1_OCTET_STRING_new(), which causes a leak.

The `KM_KEY_DESCRIPTION` structure has a `unique_id` field to hold the
unique ID as an ASN1_OCTET_STRING.  (The declaration erroneously has it
as an ASN1_INTEGER, but that has no effect as both are typedef'ed to the
same underlying `struct asn1_string_st` type.)

The `KM_KEY_DESCRIPTION` structure also has a corresponding
ASN1_SEQUENCE declaration, which builds a table of metadata about the
fields in the ASN1 SEQUENCE. The corresponding
IMPLEMENT_ASN1_FUNCTIONS(KM_KEY_DESCRIPTION) macro invocation builds
the KM_KEY_DESCRIPTION_new() function based on an invocation of
ASN1_item_new() that uses this metadata table.

The ASN1_item_new() implementation will end up calling
ASN1_STRING_type_new() for the OCTET_STRING fields, which means that
they are already initialized, and the explicit call to
ASN1_OCTET_STRING_new() overwrites the pointer without freeing the
allocated data.

Test: VtsAidlKeyMintTargetTest --gtest_filter="*UniqueId*default"
Test: with manually instrumented allocator
Bug: 266179549
Change-Id: I1814d73f891179a9565ef619545b3170039a7ec1
2 files changed