fixed memory leak
also, use sc_file_free instead of free fixes https://oss-fuzz.com/testcase-detail/4905082200260608
This commit is contained in:
parent
2493c5de07
commit
ea2991ea69
@ -253,8 +253,7 @@ static int sc_pkcs15emu_atrust_acos_init(sc_pkcs15_card_t *p15card)
|
||||
if (r != SC_SUCCESS || !file)
|
||||
return SC_ERROR_INTERNAL;
|
||||
/* set the application DF */
|
||||
if (p15card->file_app)
|
||||
free(p15card->file_app);
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = file;
|
||||
|
||||
return SC_SUCCESS;
|
||||
|
@ -169,7 +169,10 @@ static int sc_pkcs15emu_dnie_init(sc_pkcs15_card_t * p15card)
|
||||
}
|
||||
|
||||
/* Set root path of this application */
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = sc_file_new();
|
||||
if (NULL == p15card->file_app)
|
||||
LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_ENOUGH_MEMORY);
|
||||
sc_format_path("3F00", &p15card->file_app->path);
|
||||
|
||||
/* Load TokenInfo */
|
||||
|
@ -425,8 +425,7 @@ static int sc_pkcs15emu_gemsafeV1_init( sc_pkcs15_card_t *p15card)
|
||||
if (r != SC_SUCCESS || !file)
|
||||
return SC_ERROR_INTERNAL;
|
||||
/* set the application DF */
|
||||
if (p15card->file_app)
|
||||
free(p15card->file_app);
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = file;
|
||||
|
||||
return SC_SUCCESS;
|
||||
|
@ -163,8 +163,7 @@ static int sc_pkcs15emu_pteid_init(sc_pkcs15_card_t * p15card)
|
||||
if (rv != SC_SUCCESS || !file)
|
||||
return SC_ERROR_INTERNAL;
|
||||
/* set the application DF */
|
||||
if (p15card->file_app)
|
||||
free(p15card->file_app);
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = file;
|
||||
|
||||
/* Load TokenInfo */
|
||||
|
@ -261,8 +261,7 @@ static int sc_pkcs15emu_starcert_init(sc_pkcs15_card_t *p15card)
|
||||
if (r != SC_SUCCESS || !file)
|
||||
return SC_ERROR_INTERNAL;
|
||||
/* set the application DF */
|
||||
if (p15card->file_app)
|
||||
free(p15card->file_app);
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = file;
|
||||
|
||||
return SC_SUCCESS;
|
||||
|
@ -345,8 +345,7 @@ static int sc_pkcs15_tccardos_init_func(sc_pkcs15_card_t *p15card)
|
||||
if (r != SC_SUCCESS || file == NULL)
|
||||
return SC_ERROR_INTERNAL;
|
||||
/* set the application DF */
|
||||
if (p15card->file_app)
|
||||
free(p15card->file_app);
|
||||
sc_file_free(p15card->file_app;
|
||||
p15card->file_app = file;
|
||||
|
||||
return SC_SUCCESS;
|
||||
|
@ -966,6 +966,7 @@ sc_pkcs15_bind_internal(struct sc_pkcs15_card *p15card, struct sc_aid *aid)
|
||||
if (err != SC_SUCCESS)
|
||||
sc_log(ctx, "unable to enumerate apps: %s", sc_strerror(err));
|
||||
}
|
||||
sc_file_free(p15card->file_app);
|
||||
p15card->file_app = sc_file_new();
|
||||
if (p15card->file_app == NULL) {
|
||||
err = SC_ERROR_OUT_OF_MEMORY;
|
||||
|
Loading…
Reference in New Issue
Block a user