dir: Correctly free allocated memory on error
Thanks oss-fuzz https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19265
This commit is contained in:
parent
17d9d8450c
commit
708cedbdad
|
@ -118,6 +118,7 @@ parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen, int rec_nr)
|
|||
if (asn1_dirrecord[2].flags & SC_ASN1_PRESENT && path_len > 0) {
|
||||
/* application path present: ignore AID */
|
||||
if (path_len > SC_MAX_PATH_SIZE) {
|
||||
free(app->label);
|
||||
free(app);
|
||||
LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Application path is too long.");
|
||||
}
|
||||
|
@ -135,6 +136,7 @@ parse_dir_record(sc_card_t *card, u8 ** buf, size_t *buflen, int rec_nr)
|
|||
if (asn1_dirrecord[3].flags & SC_ASN1_PRESENT) {
|
||||
app->ddo.value = malloc(ddo_len);
|
||||
if (app->ddo.value == NULL) {
|
||||
free(app->label);
|
||||
free(app);
|
||||
LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate DDO value");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue