profile.c: fixed potential resource leak

This commit is contained in:
Frank Morgner 2015-10-09 17:58:11 +02:00
parent fd904fbcb8
commit 9e1a5447d4
1 changed files with 4 additions and 0 deletions

View File

@ -595,6 +595,8 @@ sc_profile_get_file_instance(struct sc_profile *profile, const char *name,
file->id += index;
if(file->type == SC_FILE_TYPE_BSO) {
r = sc_profile_add_file(profile, name, file);
if (r < 0)
sc_file_free(file);
LOG_TEST_RET(ctx, r, "Profile error: cannot add BSO file");
}
else if (file->path.len) {
@ -602,6 +604,8 @@ sc_profile_get_file_instance(struct sc_profile *profile, const char *name,
file->path.value[file->path.len - 1] = file->id & 0xFF;
r = sc_profile_add_file(profile, name, file);
if (r < 0)
sc_file_free(file);
LOG_TEST_RET(ctx, r, "Profile error: cannot add file");
}